feat(field): add WithSuggestedValue for GUI-only defaults - #1024
Conversation
WithDefaultValue feeds both the CLI/runtime flag default (which viper injects into the connector config when a field is left unset) and the exported config schema default (which the c1 GUI uses to pre-populate a field when configuring a new connector). That coupling makes adding a default to an existing field a breaking change: existing connectors whose stored config omits the field suddenly have the default injected at runtime, bypassing any connector-side "unset means use my own defaults" handling. WithSuggestedValue sets a default that is surfaced ONLY in the exported schema (GUI pre-population). It is not registered as the flag default, so nothing is injected at runtime when the field is unset. Existing connectors keep their prior behavior; new connectors get the suggested value pre-filled in the GUI and stored explicitly. WithDefaultValue is unchanged, so existing connectors depending on its behavior are unaffected. When both are set, the suggested value wins for schema export while the default value still governs the flag default. Co-authored-by: c1-squire-dev[bot] <c1-squire-dev[bot]@users.noreply.github.com>
General PR Review: feat(field): add WithSuggestedValue for GUI-only defaultsBlocking Issues: 0 | Suggestions: 1 | Threads Resolved: 0 Review SummaryThe full PR diff was scanned for security and correctness. This adds a Security IssuesNone found. Correctness IssuesNone found. Suggestions
Prompt for AI agents |
Repin from the pre-release branch pseudo-version to the released v0.20.1, which includes WithSuggestedValue (ConductorOne/baton-sdk#1024). Co-authored-by: c1-squire-dev[bot] <c1-squire-dev[bot]@users.noreply.github.com>
Adding WithDefaultValue to the noun/verb fields registered them as CLI/runtime flag defaults, which viper injects into the connector config even when a connector's stored config omits them. connector.New treats an empty noun/verb as "use the full default set", so existing connectors that never set these fields silently began syncing the narrower config default set instead of their historical full set — a breaking change. Switch to WithSuggestedValue (baton-sdk), which surfaces the defaults ONLY in the exported config schema (so the c1 GUI still pre-populates them for new connectors) without registering them as flag defaults. Existing connectors that leave the fields unset now see an empty value at runtime again and retain their prior behavior. Depends on baton-sdk WithSuggestedValue (ConductorOne/baton-sdk#1024); the go.mod pin must be updated to the released SDK version before merge. Co-authored-by: c1-squire-dev[bot] <c1-squire-dev[bot]@users.noreply.github.com>
Repin from the pre-release branch pseudo-version to the released v0.20.1, which includes WithSuggestedValue (ConductorOne/baton-sdk#1024). Co-authored-by: c1-squire-dev[bot] <c1-squire-dev[bot]@users.noreply.github.com>
* fix(config): use WithSuggestedValue for noun/verb defaults Adding WithDefaultValue to the noun/verb fields registered them as CLI/runtime flag defaults, which viper injects into the connector config even when a connector's stored config omits them. connector.New treats an empty noun/verb as "use the full default set", so existing connectors that never set these fields silently began syncing the narrower config default set instead of their historical full set — a breaking change. Switch to WithSuggestedValue (baton-sdk), which surfaces the defaults ONLY in the exported config schema (so the c1 GUI still pre-populates them for new connectors) without registering them as flag defaults. Existing connectors that leave the fields unset now see an empty value at runtime again and retain their prior behavior. Depends on baton-sdk WithSuggestedValue (ConductorOne/baton-sdk#1024); the go.mod pin must be updated to the released SDK version before merge. Co-authored-by: c1-squire-dev[bot] <c1-squire-dev[bot]@users.noreply.github.com> * chore: bump baton-sdk to v0.20.1 for WithSuggestedValue Repin from the pre-release branch pseudo-version to the released v0.20.1, which includes WithSuggestedValue (ConductorOne/baton-sdk#1024). Co-authored-by: c1-squire-dev[bot] <c1-squire-dev[bot]@users.noreply.github.com> * chore: remove unnecessary comments in config.go Co-authored-by: c1-squire-dev[bot] <c1-squire-dev[bot]@users.noreply.github.com> --------- Co-authored-by: John Allers <john.allers@c1.ai> Co-authored-by: c1-squire-dev[bot] <c1-squire-dev[bot]@users.noreply.github.com>
Problem
WithDefaultValuefeeds two independent consumers of a field's default:pkg/cli/cli.goregisters it as the cobra flag default, andv.BindPFlags+v.Unmarshalinject it into the connector config even when the stored config omits the field.pkg/field/marshal.goemits it as the exported schema default, which the c1 GUI uses to pre-populate the field for a new connector.Because of (1), adding a default to an existing field is a breaking change: existing connectors whose stored config never set the field suddenly have the default injected at runtime, bypassing any connector-side "unset ⇒ use my own defaults" logic.
Real example: baton-confluence added
WithDefaultValueto itsnoun/verbfields. Existing connectors that relied on the empty-input path (which expands to the connector's full noun/verb set) silently started syncing a narrower set.Change
Add
WithSuggestedValue, a default surfaced only in the exported schema (GUI pre-population). It is not registered as the flag default, so nothing is injected at runtime when the field is unset.SchemaField.SuggestedValuefield +WithSuggestedValue(value any)option.GetExportedDefaultValue[T]helper: prefersSuggestedValue, falls back toDefaultValue.marshal.go(schema export) now usesGetExportedDefaultValue;cli.go(flag default) is unchanged and still usesDefaultValue.WithDefaultValuebehavior is untouched, so connectors depending on it are unaffected. When both are set, the suggested value wins for schema export while the default value still governs the flag default.Usage
Tests
TestSuggestedValueandTestSuggestedValuePrecedenceinpkg/field/struct_test.gocover the split (runtime default stays empty; exported schema carries the suggested value; precedence when both set).pkg/field/...,pkg/cli/...,pkg/config/...all pass.🤖 Generated with Claude Code