Repository navigation
Description
Problem Description
devops gh api masks secrets in the reply it prints, and the mask breaks a JSON reply. A contents reply (GET repos/<owner>/<repo>/contents/<path>) of a private repository has a download_url that holds a token= query parameter. The printed reply replaces the token value and the closing quote of the string with <masked-token>, so the output is no longer valid JSON. Each caller that parses the output with json.load fails with JSONDecodeError: Expecting ',' delimiter.
Reproduction Steps
- Run
uv run devops gh api "repos/<owner>/<private-repo>/contents/<file>" > out.json. - Run
python3 -c "import json; json.load(open('out.json'))".
Expected vs Actual Behavior
- Expected: the masked output is valid JSON: the mask replaces only the secret characters inside the string, and the quotes stay.
- Actual: the output holds
...?token=<masked-token>,"type":"file",...: the closing quote ofdownload_urlis gone, andjson.loadfails at that position.
Environment Diagnostics
- devops-cli on origin/main 9e73e6d (2026-10-28).
Logs, Traces, or Terminal Output
json.decoder.JSONDecodeError: Expecting ',' delimiter: line 1 column 595 (char 594). A regex read of the content field still works, so only a caller that parses the whole reply fails.
Existing Tool Considered
The masking already exists (security/sanitizer.py). The fix is in its pattern for a query-string token: stop the match at a quote. Nothing new is built.
Proposed design
Problem statement
The devops gh api command masks secrets in its printed reply. When a JSON reply contains a token= query parameter, the mask regex also consumes the closing quote of the JSON string. The output is no longer valid JSON, and any caller that parses it with json.load fails with a JSONDecodeError.
Acceptance criteria
Requirement: Mask preserves JSON quotes
The mask SHALL replace only the secret characters of a token value and SHALL NOT consume the closing quote of the enclosing JSON string.
Scenario: JSON reply with token in download_url
- WHEN A JSON reply contains
"download_url":"https://...?token=SECRET123"and the sanitizer masks the token - THEN The output contains
"download_url":"https://...?token="andjson.loadssucceeds on the full output
Requirement: Bare token still masked
The mask SHALL still replace a token value that appears outside a quoted JSON string.
Scenario: Bare token in plain text
- WHEN The output contains
token=SECRET456with no surrounding quotes - THEN The output contains
token=
Requirement: Single-quote strings preserved
The mask SHALL NOT consume a single-quote character that closes a string.
Scenario: Single-quoted string with token
- WHEN The output contains
'download_url':'https://...?token=SECRET789' - THEN The output contains
'download_url':'https://...?token='
Existing Tool Considered
The masking logic already exists in security/sanitizer.py. The fix is a one-line change to the regex pattern for a query-string token: stop the match at a quote character. No new code is built. The written cost is the tokens to edit one regex, add one test case, and fix the pattern until it matches the expected output, plus the elapsed time of one short session.
Key questions
- What is the correct fix to the regex?: Add quote characters to the excluded set of the token-value match. Change the pattern so the token value stops at a double-quote or single-quote. For example, change
token=[^&\s]+totoken=[^&\s"']+. This preserves the quote while still masking the secret. (proposed)- Chosen: Exclude quotes from the token-value character class. Stops the match at the quote. Minimal change. Preserves both single and double quotes. Chosen.
- Rejected: Use a negative lookahead for the quote. More complex. Same result as excluding the quote from the character class. No advantage.
- Rejected: Post-process the masked string to re-insert the quote. Adds a second pass. More code to maintain. The regex fix is simpler and correct.
Open questions
- What is the current regex pattern in the sanitizer that matches a query-string token? (missing verified source)
- Does the same pattern appear elsewhere in the codebase? (missing verified source)
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Alternatives check of 2026-11-04: none.
Tool: none found.
Activity
dan-petty commentedon Oct 29, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.
The mask swallows a closing quote and breaks valid JSON output, which is a correctness defect.It breaks JSON parsing for private-repo callers but a regex workaround exists, so it is not blocking.Callers that parse the full reply with json.load fail, but a partial workaround is available.The fix is a single regex change to stop the token match at a quote character.Both fix a regex boundary bug in security/sanitizer.py, but 2471 stops a lookahead from crossing a line break while the candidate stops a match from consuming a quote.devops-cli-service commentedon Oct 29, 2026
Refine cannot set this item to Ready at a3eb41f until a person answers the questions below. Reply in a comment or edit the body, and the next refine round looks at the item again.
devops-cli-service commentedon Nov 4, 2026
Alternatives check: none
Tool: none found
Lacks:
Searches run:
Sources:
Checked on 2026-11-04. A person decides what this means for the item. The check changes no label and closes no issue.
devops-cli-service commentedon Nov 5, 2026
Released in v0.63.2: https://github.com/dan-petty/devops-cli/releases/tag/v0.63.2
devops-cli-service commentedon Nov 5, 2026
Live since 2026-11-05 20:49 UTC