Validate route identifiers as single path segments - #52
Merged
Merged
Conversation
Named helpers interpolated org, pipeline, build, number, job, and id arguments directly into the request path, so identifiers containing path or query delimiters could send a request to a different endpoint. Each identifier now must match the RFC 3986 unreserved set and must not be a dot segment; otherwise Buildkit::InvalidRouteSegment (an ArgumentError) is raised before any request is sent.
bmaynard
approved these changes
Sep 23, 2026
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Named helpers now reject any
org,pipeline,build,number,job, oridargument that isn't a single URL path segment. Invalid values raiseBuildkit::InvalidRouteSegment(a subclass ofArgumentError) before any request goes out.Client#route_segment: an allow list of RFC 3986 unreserved characters that also rejects.,.., empty strings, andnil.Client#requestalready escapes the whole path, so encoded segments would be escaped twice, and changing that would affect the publicget/post/putmethods.Why
Helpers interpolate identifiers into the request path without validating them, so an identifier containing path or query delimiters could send the request to a different endpoint than the helper intends.
Upgrade note
Code that passes a malformed identifier now gets
Buildkit::InvalidRouteSegmentlocally instead of aBuildkit::NotFoundfrom the API. If identifiers come from user input, validate them at your boundary rather than rescuing this error.Testing
Tests cover: the two reported rerouting cases, a query-only build number, dot segments, a percent-encoded delimiter, empty and
nilvalues, and theArgumentErrorcontract. The cases span org, build, build number, job, pipeline, and agent id arguments; the existing cassette specs confirm valid identifiers still hit the recorded URLs.