Skip to content

feat: warn about unknown config keys - #131

Merged
zekker6 merged 6 commits into
mainfrom
feat/warn-unknown-config-keys
Aug 13, 2026
Merged

feat: warn about unknown config keys#131
zekker6 merged 6 commits into
mainfrom
feat/warn-unknown-config-keys

Conversation

@zekker6

@zekker6 zekker6 commented Aug 12, 2026

Copy link
Copy Markdown
Owner

No description provided.

Use structures in order to parse accepted parameters, this enforces types safety as well as allows to avoid hardcoding
accepted keys for the config and use reflection.
Copilot AI lite review requested due to automatic review settings August 12, 2026 19:04
@zekker6 zekker6 changed the title Feat/warn unknown config keys feat: warn about unknown config keys Aug 12, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds end-to-end surfacing and gating of configuration mistakes by (1) warning on unknown keys, (2) failing fast on mistyped values in free-form sections, and (3) requiring explicit confirmation of setup-time warnings before handing the terminal to the sandbox workload.

Changes:

  • Introduces config schema plumbing for free-form sections ([tools.<name>], [proxy.credentials.<name>]) to validate types and report unknown keys with full dotted paths.
  • Adds a pre-launch warning confirmation prompt (with --yes to skip) and records warn/error notices for that gate.
  • Refactors tool configs to declare schema types and decode via config.DecodeSection; updates docs + changelog accordingly.

Reviewed changes

Copilot reviewed 48 out of 48 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
internal/source/source.go Removes legacy Parse helper now replaced by typed TOML decoding.
internal/source/source_test.go Drops tests for removed Parse.
internal/sandbox/tools/tool.go Adds config schema types (Config, MountModeConfig), ToolWithConfigType, and Mounting helper.
internal/sandbox/tools/registry.go Registers [tools] free-form schema and adds shared decodeConfig helper.
internal/sandbox/tools/* (many) Updates tool structs to embed Mounting and/or declare ConfigType + typed decode in Configure.
internal/sandbox/tools/schema_test.go Adds tests to keep tool schemas and mount-mode behavior consistent over time.
internal/proxy/credentials.go Registers [proxy.credentials] schema; decodes injector config as a typed struct and validates mistyped values.
internal/proxy/credentials_schema_test.go Adds tests for credential schema validation and typo reporting.
internal/config/keys.go Implements unknown-key pruning/reporting and safe dotted-path rendering for untrusted key names.
internal/config/decode.go Adds DecodeSection and validation for free-form section value types.
internal/config/config.go Wires unknown-key reporting into config loads; validates free-form tables; adjusts local-config trust prompt to show only recognized settings.
internal/config/prompt.go Switches prompt input to unbuffered line reads to avoid consuming type-ahead.
internal/prompt/prompt.go New prompt helpers (ReadLine, IsYes) shared by trust + warning confirmation prompts.
internal/prompt/prompt_test.go Adds coverage for prompt behavior, including “don’t eat type-ahead”.
internal/notice/notice.go Records warn/error notices for later confirmation; adds Raised() retention API.
internal/notice/notice_test.go Adds tests for notice raising/retention semantics.
cmd/devsandbox/main.go Adds --yes and inserts pre-launch warning confirmation gate before running isolator.
cmd/devsandbox/confirm.go Implements warning summary + interactive confirmation prompt.
cmd/devsandbox/confirm_test.go Adds tests for confirmation gating and interactive detection.
docs/configuration.md Documents unknown keys and mistyped value failures.
docs/sandboxing.md Documents startup warning confirmation behavior.
CHANGELOG.md Records the user-facing behavior changes under Unreleased.
CLAUDE.md Documents the warn vs info semantics relied on by the new gating behavior.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread internal/prompt/prompt.go
Copilot AI review requested due to automatic review settings August 13, 2026 05:26

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 48 out of 48 changed files in this pull request and generated no new comments.

Suppressed comments (2)

internal/config/prompt.go:54

  • prompt.ReadLine can return io.EOF alongside a non-empty answer (e.g. input stream ends without a trailing newline). Treating any non-nil error as fatal makes y/yes without a newline abort the trust flow, unlike the startup warning confirmation which accepts EOF and still interprets the answer.
	response, err := prompt.ReadLine(input)
	if err != nil {
		return false, fmt.Errorf("failed to read response: %w", err)
	}

internal/config/prompt.go:50

  • This trust prompt writes the question to the provided output (stderr in PromptTrustStdio). If stderr is redirected (e.g. devsandbox … 2>build.log) stdin may still be a terminal, so the current interactivity check can prompt into the log and then block waiting for input to a question the user never saw. Consider requiring both stdin and stderr to be terminals (same rationale as cmd/devsandbox/confirm.go).
	// Read response. The sandbox workload inherits this stdin, so the answer is
	// read a byte at a time - see prompt.ReadLine.

Copilot AI review requested due to automatic review settings August 13, 2026 14:00

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 48 out of 48 changed files in this pull request and generated no new comments.

Copilot AI review requested due to automatic review settings August 13, 2026 15:06
@zekker6
zekker6 merged commit 342a55e into main Aug 13, 2026
3 checks passed
@zekker6
zekker6 deleted the feat/warn-unknown-config-keys branch August 13, 2026 15:06

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 48 out of 48 changed files in this pull request and generated no new comments.

Suppressed comments (2)

cmd/devsandbox/confirm.go:69

  • writeWarningSummary always prints "X warnings" even though the list can include LevelError entries (Raised returns warn + error). That makes the header inconsistent with the per-entry labels (e.g. "[error]"). Consider adjusting the noun when any error entries are present.
	noun := "warning"
	if len(entries) > 1 {
		noun = "warnings"
	}
	fmt.Fprintf(out, "\n%d %s while preparing the sandbox:\n\n", len(entries), noun) //nolint:errcheck

cmd/devsandbox/confirm_test.go:141

  • This test currently asserts the summary header says "3 warnings..." even though the entries include one emitted via notice.Error(...). If writeWarningSummary is updated to distinguish errors in the header, this assertion needs to match.
	for _, want := range []string{
		"3 warnings while preparing the sandbox",
		"[warn] first problem",
		"[warn] second problem",
		"[error] third problem",
	} {

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