Skip to content

Formatter Incorrectly Rewrites Object Merging in List Comprehensions #209

@vitalyu

Description

@vitalyu

The Grafana Jsonnet formatter in VS Code incorrectly rewrites syntactically valid object merging (+) inside a list comprehension. It replaces an object concatenation operation with an explicit key-value pair, which is a destructive change that alters the code's meaning and assumptions about the data structure.

Steps to Reproduce:

  • VSCode plugin grafana.vscode-jsonnet 0.7.2
  • Use the VS Code command "Format Document" (or allow formatting on save).
env: [{ name: e.key } + e.value for e in std.objectKeysValues(env_)]

Actual Behavior

The formatter aggressively rewrites the line, changing the logic from object merging to direct key assignment. The code is incorrectly changed to:

env: [ { name: e.key, value: e.value } for e in std.objectKeysValues(env_) ]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions