Thanks to visit codestin.com
Credit goes to github.com

Skip to content

no trailing slash for post to /entries #1366

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
May 8, 2025

Conversation

ramonpetgrave64
Copy link
Contributor

@ramonpetgrave64 ramonpetgrave64 commented May 6, 2025

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

@ramonpetgrave64
Copy link
Contributor Author

@jku

Copy link
Member

@jku jku left a comment

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?

Copy link
Member

@jku jku left a comment

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
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
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
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 <[email protected]>
Signed-off-by: Ramon Petgrave <[email protected]>
Signed-off-by: Ramon Petgrave <[email protected]>
@ramonpetgrave64
Copy link
Contributor Author

ramonpetgrave64 commented May 7, 2025

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

Signed-off-by: Ramon Petgrave <[email protected]>
Signed-off-by: Ramon Petgrave <[email protected]>
Signed-off-by: Ramon Petgrave <[email protected]>
@woodruffw
Copy link
Member

/gcbrun

Signed-off-by: William Woodruff <[email protected]>
@woodruffw
Copy link
Member

/gcbrun

Copy link
Member

@woodruffw woodruffw left a comment

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
Copy link
Member

@jku jku left a comment

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