Skip to content

Guard against non-object JSON when switching to table mode in EnvironmentForm#4022

Draft
fiftin with Copilot wants to merge 2 commits into
developfrom
copilot/fix-review-comment-3553053067
Draft

Guard against non-object JSON when switching to table mode in EnvironmentForm#4022
fiftin with Copilot wants to merge 2 commits into
developfrom
copilot/fix-review-comment-3553053067

Conversation

Copilot AI commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

When switching extra-vars to table mode, JSON.parse output was passed directly to Object.keys() without verifying it was a plain object. Scalars, null, and arrays all satisfy Object.keys() — producing rows with numeric/character keys — so saving would silently reshape the stored JSON into an object with a different structure.

Changes

  • web/src/components/EnvironmentForm.vueextraVarsEditMode watcher, case 'table': added a type guard after JSON.parse that falls back to JSON mode if the parsed value is not a plain object:
if (extraVars === null || typeof extraVars !== 'object' || Array.isArray(extraVars)) {
  this.extraVarsEditMode = 'json';
  return;
}

Arrays ([]), strings ("abc"), numbers, and null at the root level now keep the editor in JSON mode instead of being silently converted to object-shaped rows on save.

Copilot AI changed the title [WIP] Fix code for review comment in PR #4019 Guard against non-object JSON when switching to table mode in EnvironmentForm Jul 9, 2026
Copilot finished work on behalf of fiftin July 9, 2026 16:08
Copilot AI requested a review from fiftin July 9, 2026 16:08
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