Skip to content

fix: report unedited saves as unchanged, follow Chef precedence in node ssh, surface export config errors - #260

Merged
tas50 merged 1 commit into
mainfrom
fix/edit-noop-ssh-attr-export-config
Sep 24, 2026
Merged

tas50 merged 1 commit into
mainfrom
fix/edit-noop-ssh-attr-export-config

Conversation

@tas50

@tas50 tas50 commented Sep 24, 2026

Copy link
Copy Markdown
Collaborator

Three bugs from an audit of the command layer. None needs new cinc-api surface.

Edit commands reported "Updated" for a save that changed nothing. Every edit compared before/after with reflect.DeepEqual. The server sends empty attribute maps as {}, and the editor's round trip through omitempty turns them into nil, so role edit / environment edit always sent a PUT. The existing tests stubbed the editor with a hand-built struct, so they never saw this. The fix adds an unchanged helper that compares the JSON each side would send, used at all nine edit sites.

node ssh --attribute ignored Chef precedence. A dotted path was looked up only at the top of the search row, so cloud.public_hostname (under automatic) never resolved. A plain name also tried default before override. The fix decodes the row as a cinc.Node and uses its precedence-aware AttributeString (automatic, override, normal, default). name still resolves to the node name.

policy export swallowed config errors. It called chef, _ := resolveClient(cmd), so a broken config showed up as "chef_server source requires a configured server connection", and on a fresh machine with a terminal it could start first-run setup in the middle of an offline export. The fix resolves the client only when the lock has a chef_server source, and returns its error.

Test plan

  • TestEditWithoutChangesSendsNothing (role, environment) serves the raw server body and stubs the editor with a real marshal/unmarshal round trip. It fails before the change and passes after.
  • TestSearchRowAttributeFollowsChefPrecedence: dotted path and override-over-default cases fail before the change and pass after.
  • TestPolicyExportResolvesTheServerOnlyWhenTheLockNeedsIt: a path lock exports with a broken config, and a chef_server lock reports the config error.
  • go test ./apps/cinc/cmd/ ./cli/policyfile/, go vet, gofmt clean

…de ssh, surface export config errors

Edit commands compared the object before and after the editor with
reflect.DeepEqual. The server sends empty attribute maps as {}, and the
editor's round trip through omitempty turns them into nil, so saving a
role or environment without touching it still sent a PUT and printed
"Updated". Compare the JSON each side would send instead.

node ssh --attribute looked a dotted path up only at the top of the
search row, so cloud.public_hostname (which lives under automatic) never
resolved, and a plain name tried default before override. Decode the row
as a node and use cinc-api's precedence-aware lookup.

policy export discarded every error from resolving the server client, so
a broken config surfaced as a vague "requires a configured server
connection" and a fresh machine could start first-run setup mid-export.
Resolve the client only when the lock has a chef_server source, and
return its error when it fails.

Signed-off-by: Tim Smith <tsmith84@proton.me>
@tas50
tas50 enabled auto-merge (squash) September 24, 2026 05:18
@tas50
tas50 merged commit 2d5fde2 into main Sep 24, 2026
6 checks passed
@tas50
tas50 deleted the fix/edit-noop-ssh-attr-export-config branch September 24, 2026 05:19
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.

1 participant