Skip to content

fix: raise ValueError for path-style S3 URLs missing a key - #9460

Open
nursnaaz wants to merge 1 commit into
aws:developfrom
nursnaaz:fix/s3-path-style-url-missing-key
Open

nursnaaz wants to merge 1 commit into
aws:developfrom
nursnaaz:fix/s3-path-style-url-missing-key

Conversation

@nursnaaz

Copy link
Copy Markdown

Which issue(s) does this change fix?

None filed. Found by code review.

Why is this change necessary?

parse_s3_url raises IndexError for a path-style S3 URL that has no object key, such as https://s3.us-east-1.amazonaws.com/bucket or https://s3.us-east-1.amazonaws.com/. Callers such as is_s3_protocol_url only catch ValueError, so a CodeUri or TemplateURL like that ends sam package or sam delete with a traceback. s3://foo and https://s3.us-east-1.amazonaws.com already raise ValueError.

How does it address the issue?

_parse_path_style_s3_url only fills in the bucket and key when both are present, so these URLs raise the same ValueError as the other invalid forms. Two URLs were added to the existing invalid-URL unit test.

What side effects does this change have?

None for valid URLs. Invalid path-style URLs now raise ValueError instead of IndexError.

Mandatory Checklist

PRs will only be reviewed after checklist is complete

  • Review the generative AI contribution guidelines. Generated by AI tools, and reviewed by Mohamed Noordeen Alaudeen (@nursnaaz).
  • Add input/output type hints to new functions/methods (no new functions)
  • Write design document if needed (Do I need to write a design document?) (not needed)
  • Write/update unit tests
  • Write/update integration tests
  • Write/update functional tests if needed
  • make pr passes (I ran the related unit tests, 338 passed, plus ruff, black and mypy on the changed files; CI will run the full target)
  • make update-reproducible-reqs if dependencies were changed (no dependency change)
  • Write documentation (not needed)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@nursnaaz
nursnaaz requested a review from a team as a code owner November 21, 2026 14:36
@github-actions github-actions Bot added pr/external stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. labels Nov 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr/external stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant