Repository navigation
feat(groups): allowDuplicateName create opt-in + duplicate-adoption guidance - #79
Merged
Merged
Conversation
…uidance (#75) Groups declare `allowDuplicateName: true` to opt into CT's `force: true` same-name create guard (`POST /groups` 400s `forbidden.duplicate.group` otherwise) — needed when two groups legitimately share a name (e.g. an archived and an active event signup). The flag is create-body-only: never diffed, never in state, never sent on update, never trips the unknown-field warning. When a group create 400s on this guard without the opt-in, the stop message now appends guidance pointing at adopting the likely-unmanaged existing group (`ct adopt group <id> --key <key>`) or setting the flag if the duplicate is intentional — reusing the shared formatError output rather than forking it. Evidence for the force-param shape: ChurchTools OpenAPI spec's POST /groups request body documents `force: boolean` ("Need to be true, if another group with that name already exists"); its analogous POST /persons 400 documents the `{ message, messageKey, translatedMessage }` envelope (`forbidden.duplicate.person`) that issue #75's live dev rehearsal confirms groups also use (`forbidden.duplicate.group`).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
allowDuplicateName: trueto opt into ChurchTools'forcesame-name group-creation flag, sent only on the CREATEPOST /groupsbody — never diffed, never in state, never sent on update, never adopted, and never trips the unknown-field warning.formatErroroutput, not a forked formatter) pointing at either adopting the likely-unmanaged existing group (ct adopt group <id> --key <key>) or settingallowDuplicateName: trueif the duplicate is intentional.docs/group-field-decisions.md's decision table now cover the flag.Closes #75
Evidence for the force-param shape
POST /groupsin the ChurchTools OpenAPI spec (churchtools-openapi.json, operationIdpost-groups) documents a top-level body boolean field:So the opt-in is
force: truein the JSON body — not a?force=truequery param.POST /groups's own 400 response is undocumented beyond "Bad Request" in the spec, but the analogousPOST /persons400 (same duplicate-guard pattern) documents the exact error envelope:{ "message": "Duplicate found. Use force flag to create person with same name.", "messageKey": "forbidden.duplicate.person", "translatedMessage": "..." }Issue #75's own live dev-rehearsal report confirms the group case matches this shape verbatim, with
messageKey: "forbidden.duplicate.group"and message text "Duplicate found. Use force flag to create group with same name." — the implementation checks the messageKey first, falling back to a text match (duplicate + "force flag" + "group") for defense in depth. No live instance was contacted for this PR.Test plan
npm test— 531 passed, 5 skipped (0 failed); 23 new/updated assertions acrosstests/execute.test.ts,tests/context.test.ts,tests/plan.test.tscover: force sent only on CREATE with the flag, force omitted without it, update path untouched even if a stale item carried the flag, unknown-field warning does not fire, non-boolean/non-group rejected at DSL eval time, duplicate-400 stop message contains the guidance (via messageKey and via text fallback), guidance suppressed when the flag is already set or the 400 is unrelated.npm run typecheck— cleannpm run lint— clean