Fix: Correctly calculate URL-encoded length#118
Open
dtaniwaki wants to merge 4 commits intox-motemen:masterfrom
Open
Fix: Correctly calculate URL-encoded length#118dtaniwaki wants to merge 4 commits intox-motemen:masterfrom
dtaniwaki wants to merge 4 commits intox-motemen:masterfrom
Conversation
ohbarye
reviewed
Jan 17, 2026
lib/git/pr/release/cli.rb
Outdated
| # Longer than 256 characters are not supported in the query. | ||
| # GitHub's Issue Search API has a 256 character limit for the KEYWORD section only. | ||
| # Qualifiers like "repo:", "is:" are not counted toward this limit. | ||
| # The limit applies to the URL-encoded length of keywords. |
Collaborator
There was a problem hiding this comment.
Thank you for the detailed investigation and suggestion. I understand that we should exclude qualifiers from the calculation.
Regarding the URL encoding, I may not fully understand the issue yet. The SHAs passed to the q parameter consist only of [0-9a-f], so URL encoding doesn't change their length. Additionally, spaces simply become + (1 character). Given this, it seems we could calculate the length without using URI.encode_www_form_component at all.
With that in mind, wouldn't it be correct to simply subtract the qualifier length from the current calculation?
-if query.length + 1 + sha.length >= 256
+if (query.length + 1 + sha.length) - query_base.length >= 256
Author
There was a problem hiding this comment.
That makes sense. I will fix the code.
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.
Thank you for maintaining this wonderful tool. I've been using git-pr-release in our workflow and it has been incredibly helpful.
I noticed an issue (#103) where the GitHub Issue Search API query length validation wasn't working correctly. The problem was that the code was checking the raw string length against the 256 character limit, but GitHub's API actually applies this limit to the URL-encoded length of keywords only (qualifiers like
repo:andis:don't count toward the limit).This means when the query contains special characters like
:or/, they get encoded as%3Aand%2F, making the actual encoded string longer than expected. This could cause the query to fail even when the raw string appeared to be under the limit.I've updated the code to properly calculate the URL-encoded length before batching the queries, and refactored the query building logic to be clearer about what's being counted. I also added tests to verify the encoding calculations and ensure that batched queries never exceed the limit, including edge cases with long repository names.
Hope this helps! Let me know if you'd like any changes.