fix(config): use WithSuggestedValue for noun/verb defaults - #45
Conversation
Connector PR Review: fix(config): use WithSuggestedValue for noun/verb defaultsBlocking Issues: 0 | Suggestions: 0 | Threads Resolved: 0 Review SummaryThe full PR diff was scanned for security and correctness. The substantive change swaps Security IssuesNone found. Correctness IssuesNone found. SuggestionsNone. |
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>
Co-authored-by: c1-squire-dev[bot] <c1-squire-dev[bot]@users.noreply.github.com>
78ca058 to
123e355
Compare
Problem
Commit 6d27d6d added
field.WithDefaultValue(defaultNouns)/WithDefaultValue(defaultVerbs)to thenoun/verbconfig fields.WithDefaultValuefeeds two things:pkg/cliregisters it as the cobra flag default, and viper (BindPFlags+Unmarshal) injects it into the connector config even when the stored config omits the field;connector.New→filterArgstreats an empty noun/verb as "use the full default set" (attachment, blogpost, comment, page, space+ 8 verbs). Because of (1), an existing connector whose stored config never setnoun/verbnow gets["space"]+ 6 verbs injected at runtime →filterArgsnarrows the sync, dropping nouns{attachment, blogpost, comment, page}and verbs{archive, update}. That's a silent breaking change.Fix
Use
field.WithSuggestedValue(baton-sdk v0.20.1, from ConductorOne/baton-sdk#1024) instead ofWithDefaultValue. The suggested value is surfaced only in the exported schema — the GUI still pre-populatesnoun/verbfor new connectors — but it is not registered as the flag default, so nothing is injected at runtime when the field is unset. Existing connectors that leave the fields unset see an empty value at runtime again and keep their historical full-set behavior.Verification
./baton-confluence config(exported schema):noun -> ["space"],verb -> [administer, create, delete, export, read, restrict_content]— GUI pre-population intact.Noun=[],Verb=[]— no injection;filterArgsreturns the full default set.go build ./cmd/baton-confluenceandgo test ./...pass against baton-sdk v0.20.1.🤖 Generated with Claude Code