Skip to content

Reject config paths that descend into non-struct fields - #2107

Open
ajavanma wants to merge 1 commit into
NVIDIA:mainfrom
ajavanma:fix/config-set-path-panic
Open

ajavanma wants to merge 1 commit into
NVIDIA:mainfrom
ajavanma:fix/config-set-path-panic

Conversation

@ajavanma

Copy link
Copy Markdown

Description

Reject config --set keys that continue past a non-struct field. A key such as disable-require.extra=true currently reaches a boolean during recursive TOML-field lookup and panics. Checking the current type before enumerating fields returns the existing wrapped invalid-option error instead.

Add parser and real command-handler regressions for boolean, string, slice, and pointer fields. Tests also verify that invalid input preserves the configuration file and that valid nested paths, list values, and optional boolean values still work.

Checklist

  • No secrets, sensitive information, or unrelated changes
  • Unit tests passing (make test)
  • Lint checks passing (make lint)
  • Test cases are added for new code paths
  • Commits are signed-off and cryptographically signed

Testing

  • Saved audit reproduction fails on unchanged main 3a6c050d9c0c7b2516ce17e2190fb7e71b741f82.
  • go test ./cmd/nvidia-ctk/config -run '^TestConfigCommandSet$' -count=1: four malformed-path cases fail on unchanged production code; valid controls pass.
  • go test ./cmd/nvidia-ctk/config -count=1: passes with the fix.
  • make fmt, make build, make test: pass on Linux ARM64 with Go 1.26.1.
  • make lint: passes with golangci-lint 2.13.2, zero issues.
  • Built nvidia-ctk binary against temporary files: all four malformed paths return exit 1 with invalid-option errors, no panic, and unchanged file contents. A valid multi-set command preserves nested strings, serializes lists, and removes an optional boolean set to nil.
  • No GPU/container-runtime end-to-end checks run; this change affects configuration-key validation only. No dependency changes.

Reject dotted --set keys that continue past a boolean, string, slice,
or pointer leaf before enumerating fields with reflection. Return the
existing invalid-option error instead of panicking.

Cover malformed paths through the parser and command handler, preserve
configuration files on failure, and retain valid nested and optional
boolean settings.

Signed-off-by: Arash Javanmardi <arash@javanmardi.info>
@copy-pr-bot

copy-pr-bot Bot commented Sep 18, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@ajavanma
ajavanma force-pushed the fix/config-set-path-panic branch from 91831b1 to 819bb3f Compare September 18, 2026 09:08
@myeolenv

Copy link
Copy Markdown

Thanks for the contribution. We will review this PR soon.

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