Skip to content

fix(ci): Resolve double JSON.parse in redirect chain lint workflow#18705

Open
s1gr1d wants to merge 1 commit into
masterfrom
sig/fix-redirect-chains
Open

fix(ci): Resolve double JSON.parse in redirect chain lint workflow#18705
s1gr1d wants to merge 1 commit into
masterfrom
sig/fix-redirect-chains

Conversation

@s1gr1d

@s1gr1d s1gr1d commented Jul 13, 2026

Copy link
Copy Markdown
Member

Fix a regression in CI (breaks on every new PR right now)

Workflow added in: #18620

Fix SyntaxError: "[object Object]" is not valid JSON in the redirect chain lint CI step by removing redundant double-parse of the lint result output.

@s1gr1d s1gr1d requested a review from sfanahata July 13, 2026 11:49
@vercel

vercel Bot commented Jul 13, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
develop-docs Ready Ready Preview Jul 13, 2026 11:56am
sentry-docs Ready Ready Preview Jul 13, 2026 11:56am

Request Review

try {
const jsonString = JSON.parse(lintResultJsonString);
lintResult = JSON.parse(jsonString);
lintResult = typeof lintResultRaw === 'string' ? JSON.parse(lintResultRaw) : lintResultRaw;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The lint_result output is a JSON-encoded string. A single JSON.parse is not enough to convert it into an object, causing the script to fail silently.
Severity: MEDIUM

Suggested Fix

The lintResultRaw variable is a JSON-encoded string that needs to be parsed twice to become a usable JavaScript object. Restore the double JSON.parse call, which will first unescape the string and then parse the resulting JSON string into an object.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: .github/workflows/lint-redirect-chains.yml#L74

Potential issue: The `steps.lint.outputs.lint_result` variable is a string containing
JSON. The `toJSON()` function in the GitHub workflow escapes this string, creating a
JSON-encoded string. The code then uses a single `JSON.parse` on this value. This only
reverses the `toJSON()` escaping, resulting in `lintResult` being a string of JSON, not
a JavaScript object. Consequently, attempts to access properties like
`lintResult.redirectChains` and `lintResult.contentLinkIssues` return `undefined`. This
causes the script to silently fail and not post the linting results as a PR comment.

Did we get this right? 👍 / 👎 to inform future reviews.

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.

2 participants