Skip to content

--file accepts unknown fields that the editor rejects #268

Description

@tas50

The interactive editors validate on save with strictJSON[T]() (apps/cinc/cmd/editor.go), which rejects any key the model type doesn't know. That way a typo, or a field the CLI would drop, surfaces as an error instead of silently vanishing and making the edit look like "no change".

--file goes through readJSONFile[T] (apps/cinc/cmd/common.go), a plain json.Unmarshal, so the same unknown key is silently dropped. For example, cinc role edit web --file role.json with a misspelled "overide_attributes" saves without it and reports success.

Make readJSONFile decode with DisallowUnknownFields too, so both paths agree. Watch out for files exported from knife, which carry json_class and chef_type. Either accept those two keys explicitly, or have the cinc-api types model them, so a knife export still loads.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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