Skip to content

fix: adopt group --children-of ignores ChurchTools domain resources #136

Closed

Description

@bwl21

Problem

A live ChurchTools instance contains group #2424 with three visible child groups, but:

ct adopt group --children-of 2424

returns:

No groups matched — nothing to adopt.

Cause

GET /groups/{id}/children is currently treated as a direct array of objects with an id property. The ChurchTools OpenAPI documents a collection envelope whose entries are domain resources:

{
  "data": [
    {
      "domainIdentifier": "41",
      "domainType": "group",
      "apiUrl": "/groups/41"
    }
  ],
  "meta": {}
}

The API client already unwraps the normal data envelope, but traversal then ignores every entry because domain resources expose domainIdentifier instead of id.

The current implementation also treats every 404 from the children endpoint as an empty leaf, even though the OpenAPI defines 404 as resource not found.

Expected behavior

ct adopt group --children-of 2424 --dry-run discovers all existing descendants and proposes their adoption.

Traversal must retain:

  • recursive traversal
  • parent-before-child order
  • exclusion of the selected root
  • cycle protection
  • duplicate suppression
  • existing key and state behavior

Acceptance criteria

  • Support direct arrays and { data: [...] } responses.
  • Support classic child objects with id.
  • Support ChurchTools domain resources with numeric domainIdentifier and a sensible apiUrl fallback.
  • Reject unknown response objects instead of silently treating them as an empty subtree.
  • Propagate unexpected API errors, including 404 for an existing traversal target.
  • Add regression tests for all supported response shapes and error behavior.
  • npm test, npm run typecheck, and npm run lint pass.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    triageUnsorted intake — decide in the weekly sweep

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions