#1558: validate lock reason against documented domain#1849
Merged
yegor256 merged 2 commits intojcabi:masterfrom May 7, 2026
Merged
#1558: validate lock reason against documented domain#1849yegor256 merged 2 commits intojcabi:masterfrom
yegor256 merged 2 commits intojcabi:masterfrom
Conversation
The test rejectsInvalidLockReason expects IllegalArgumentException for a reason outside the documented domain (off-topic, too heated, resolved, spam) but currently the call goes through to the server, since RtIssue performs no validation. The test locksWithValidReason verifies that an allowed reason still issues a PUT /lock with the lock_reason payload.
RtIssue.lock(String) now rejects any reason outside the four values documented for the GitHub Lock-an-issue endpoint (off-topic, too heated, resolved, spam) by throwing IllegalArgumentException before issuing the HTTP request. The puzzle text in Issue.java is removed since the validation requested by it is now in place and covered by tests.
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.
Closes #1558.
This PR resolves the PDD puzzle in
Issue.javalines 36-40 by adding lock-reason validation toRtIssue.lock(String).Changes
#1558: add failing test demonstrating absent lock reason validation— adds two tests toRtIssueTest:locksWithValidReason— verifies thatlock("off-topic")issuesPUT /lockwith body{"lock_reason":"off-topic"}against aMkGrizzlyContainerand accepts the204 No Contentresponse.rejectsInvalidLockReason— expectsIllegalArgumentExceptionfor an unknown reason, which fails on master becauseRtIssue.lockperforms no validation and lets the request go through to the server.#1558: validate lock reason against documented domain—RtIssue.lock(String)now checks the supplied reason against the four values documented for the GitHub Lock-an-issue endpoint (off-topic,too heated,resolved,spam) before issuing the HTTP request, throwingIllegalArgumentExceptionotherwise. The puzzle text inIssue.javais removed.Reference: https://docs.github.com/en/rest/issues/issues#lock-an-issue
Local verification
mvn -B -DskipITs testreports 715 tests, 0 failures, 0 errors, 6 skipped.CI note
The
mvn (ubuntu-24.04, 17)job currently fails onmaster(run 25203863689) and on every recent renovate PR (e.g. #1848) due to ~837 pre-existing Qulice/PMD violations across the codebase that are unrelated to this change. Fixing those is out of scope here. The other CI checks (codecov, actionlint, copyrights, markdown-lint, pdd, reuse, typos, xcop, yamllint) are expected to pass.