Skip to content

#1558: validate lock reason against documented domain#1849

Merged
yegor256 merged 2 commits intojcabi:masterfrom
bibonix:fix/1558-lock-reason-validation
May 7, 2026
Merged

#1558: validate lock reason against documented domain#1849
yegor256 merged 2 commits intojcabi:masterfrom
bibonix:fix/1558-lock-reason-validation

Conversation

@bibonix
Copy link
Copy Markdown
Contributor

@bibonix bibonix commented May 4, 2026

Closes #1558.

This PR resolves the PDD puzzle in Issue.java lines 36-40 by adding lock-reason validation to RtIssue.lock(String).

Changes

  1. #1558: add failing test demonstrating absent lock reason validation — adds two tests to RtIssueTest:

    • locksWithValidReason — verifies that lock("off-topic") issues PUT /lock with body {"lock_reason":"off-topic"} against a MkGrizzlyContainer and accepts the 204 No Content response.
    • rejectsInvalidLockReason — expects IllegalArgumentException for an unknown reason, which fails on master because RtIssue.lock performs no validation and lets the request go through to the server.
  2. #1558: validate lock reason against documented domainRtIssue.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, throwing IllegalArgumentException otherwise. The puzzle text in Issue.java is removed.

Reference: https://docs.github.com/en/rest/issues/issues#lock-an-issue

Local verification

mvn -B -DskipITs test reports 715 tests, 0 failures, 0 errors, 6 skipped.

CI note

The mvn (ubuntu-24.04, 17) job currently fails on master (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.

bibonix added 2 commits May 4, 2026 17:04
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.
@yegor256 yegor256 merged commit 60a74b0 into jcabi:master May 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Issue.java:61-66: Implement lock reason validation....

2 participants