Skip to content

no trailing slash for post to /entries#1366

Merged
jku merged 8 commits into
sigstore:mainfrom
ramonpetgrave64:trailining-slash
May 8, 2025
Merged

no trailing slash for post to /entries#1366
jku merged 8 commits into
sigstore:mainfrom
ramonpetgrave64:trailining-slash

Conversation

@ramonpetgrave64

@ramonpetgrave64 ramonpetgrave64 commented May 6, 2025

Copy link
Copy Markdown
Contributor

Client support for Rekor V2: sigstore-python

Summary

Resolves #1365

by stripping the any trailing slash from the POST request.

Release Note

Removed trailing "/" in POST requests to "/entries".

Documentation

None

Signed-off-by: Ramon Petgrave <ramon.petgrave64@gmail.com>
@ramonpetgrave64

Copy link
Copy Markdown
Contributor Author

@jku

@jku jku left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you're right here, thanks.

  • I'd make the fix in RekorLog.entries() though: no need to rstrip() if we never add the slash in the first place. The other use cases where the url is used look like they will keep working just fine
  • Could also do the same fix of not adding the trailing slash in RekorEntries.retrieve() and RekorClient.log() --- the situations look identical there (I don't think these end points get used in normal client use so they're not important but IMO makes sense to fix all the cases)

WDYT?

@jku jku left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a line into CHANGELOG as well.

(I'm marking this "request changes" for the changelog: feel free to make your own decision on the suggestions in previous comment)

@woodruffw

Copy link
Copy Markdown
Member

Hey @ramonpetgrave64, thanks for the PR!

  • I'd make the fix in RekorLog.entries() though: no need to rstrip() if we never add the slash in the first place. The other use cases where the url is used look like they will keep working just fine

Yeah, I think I'd prefer a "never add the slash" approach here versus "add it and then remove it sometimes" -- IMO that'll be easier to read and follow.

(In terms of doing that -- I think we can just modifying the underlying urljoin calls that build up these different routes.)

@ramonpetgrave64

Copy link
Copy Markdown
Contributor Author

urljoin doesn't work like other "join" functions. Removing the slashes altogether would make everything more complicated when we need to add the slashes. If you both still prefer, I could do it the way you suggest.

@woodruffw

Copy link
Copy Markdown
Member

urljoin doesn't work like other "join" functions. Removing the slashes altogether would make everything more complicated when we need to add the slashes. If you both still prefer, I could do it the way you suggest.

Ah yeah, I forgot about the wonky join behavior even when there's no leading or trailing /. Sigh.

Given that, I think maybe we'd be better off uisng f-strings here and building up the URL that way, to avoid having to strip things post facto. Alternatively, we could use the rfc3986 package (which we probably already indirectly depend on), since it has URIBuilder.add_path and URIBuilder.extend_path for exactly this purpose.

Signed-off-by: Ramon Petgrave <ramon.petgrave64@gmail.com>
Signed-off-by: Ramon Petgrave <ramon.petgrave64@gmail.com>
Signed-off-by: Ramon Petgrave <ramon.petgrave64@gmail.com>
@ramonpetgrave64

ramonpetgrave64 commented May 7, 2025

Copy link
Copy Markdown
Contributor Author

@woodruffw rfc3986 isn't currently a dependency, so I changed to using f-strings. Also added the changelog entry.

Comment thread sigstore/_internal/rekor/client.py Outdated
Signed-off-by: Ramon Petgrave <ramon.petgrave64@gmail.com>
Signed-off-by: Ramon Petgrave <ramon.petgrave64@gmail.com>
Signed-off-by: Ramon Petgrave <ramon.petgrave64@gmail.com>
@woodruffw

Copy link
Copy Markdown
Member

/gcbrun

Comment thread CHANGELOG.md Outdated
Signed-off-by: William Woodruff <william@yossarian.net>
@woodruffw

Copy link
Copy Markdown
Member

/gcbrun

@woodruffw woodruffw left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @ramonpetgrave64!

@jku will need to re-review since I've tweaked the CHANGELOG, but this LGTM.

@woodruffw woodruffw added the refactoring Refactoring tasks. label May 7, 2025
@ramonpetgrave64 ramonpetgrave64 requested a review from jku May 8, 2025 12:40

@jku jku left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@jku jku merged commit 7b0100b into sigstore:main May 8, 2025
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactoring Refactoring tasks.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Trailing slash in "/entries" path

3 participants