Skip to content

Conversation

@jsalaber
Copy link
Contributor

@jsalaber jsalaber commented Jan 2, 2026

Changes

  • used stringified value of json variables for recommendation comment

Copilot AI review requested due to automatic review settings January 2, 2026 16:57
@jsalaber jsalaber requested a review from a team as a code owner January 2, 2026 16:57
@jsalaber jsalaber requested a review from a team January 2, 2026 16:57
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes handling of JSON-type variables in the stale variable recommendation system by stringifying JSON values before displaying them in code comments.

Key changes:

  • Added JSON stringification for recommended values when variable type is 'JSON'
  • Fixed a bug where falsy values (false, 0, "") were incorrectly replaced with defaultValue by changing || to ?? operator

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@jsalaber jsalaber force-pushed the COR-3917-use-stringified-json-value-reco branch from 414d35d to 559dd35 Compare January 2, 2026 18:24
Copilot AI review requested due to automatic review settings January 2, 2026 19:14
@jsalaber jsalaber force-pushed the COR-3917-use-stringified-json-value-reco branch from 559dd35 to d971171 Compare January 2, 2026 19:14
@jsalaber jsalaber merged commit 3c470e2 into main Jan 2, 2026
13 checks passed
@jsalaber jsalaber deleted the COR-3917-use-stringified-json-value-reco branch January 2, 2026 19:15
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +290 to +301
const indentation = indent ? ' ' : ''
const jsonString = JSON.stringify(parsed, null, 4)
return (
'\n' +
jsonString
.split('\n')
.map((line) =>
line ? indentation + line : line,
)
.join('\n') +
'\n'
)
Copy link

Copilot AI Jan 2, 2026

Choose a reason for hiding this comment

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

The indentation logic doesn't add the comment prefix (' * ') that's required for block comments. The blockComment function expects staleWarning to be formatted as a single line with the comment prefix already applied (see line 41 in blockComment). The current implementation adds indentation but not the ' * ' prefix needed for multi-line comment content. This will result in malformed JSDoc comments when the recommended value is a JSON object.

Copilot uses AI. Check for mistakes.
'\n'
)
}
} catch {
Copy link

Copilot AI Jan 2, 2026

Choose a reason for hiding this comment

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

The empty catch block silently ignores JSON parsing errors. While this might be intentional as a fallback mechanism, it would be better to add a comment explaining why parsing errors are being ignored, or at minimum add an empty comment to make it clear the empty block is intentional.

Suggested change
} catch {
} catch {
// If JSON parsing fails, fall back to using the raw recommendedValue.

Copilot uses AI. Check for mistakes.
Comment on lines +104 to +106
const value =
releaseVariation?.variables?.[variable.key] ??
variable.defaultValue
Copy link

Copilot AI Jan 2, 2026

Choose a reason for hiding this comment

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

The change from the logical OR operator (||) to the nullish coalescing operator (??) changes the behavior. The || operator would use defaultValue for any falsy value (0, false, '', null, undefined), while ?? only uses it for null or undefined. This means if releaseVariation?.variables?.[variable.key] is 0, false, or '', the old code would have used defaultValue but the new code will use the falsy value. Ensure this behavioral change is intentional.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants