Skip to content

fix(account-status-lifecycle-test): read resource-level status for SDK compatibility#102

Merged
luisina-santos merged 2 commits into
mainfrom
luisinasantos/status-lifecycle-test-resource-status
Jul 22, 2026
Merged

fix(account-status-lifecycle-test): read resource-level status for SDK compatibility#102
luisina-santos merged 2 commits into
mainfrom
luisinasantos/status-lifecycle-test-resource-status

Conversation

@luisina-santos

Copy link
Copy Markdown
Contributor

Problem

The account-status-lifecycle-test action reads user status only from the deprecated UserTrait annotation (UserTrait_Status_Status, e.g. STATUS_ENABLED).

Recent baton-sdk versions moved status to a resource-level attribute (Status_ResourceStatus, e.g. RESOURCE_STATUS_ENABLED). When a connector migrates to WithResourceStatus(...) and sets only the resource-level status:

  • The SDK mirrors trait → resource, but not resource → trait.
  • NewUserTrait defaults an unset trait status to STATUS_ENABLED.

So the test always reads STATUS_ENABLED from the trait, and disable verifications fail even when the account was correctly disabled:

User 2 current status: STATUS_ENABLED
✗ User is not disabled as expected

(Hit while migrating baton-looker off the deprecated trait options — the connector builds and disables correctly, but this shared test couldn't observe the resource-level status.)

Fix

get_user_status now reads both locations and:

  1. Prefers the resource-level resource.status.status, normalizing RESOURCE_STATUS_* → the trait form STATUS_*.
  2. Falls back to the deprecated trait status.status only when no resource-level status is present.
  3. Treats *_UNSPECIFIED as absent, so the unreliable defaulted trait value never masks a real resource-level status.

Downstream comparisons (is_user_enabled, summaries) are unchanged — they still compare against STATUS_ENABLED / STATUS_DISABLED.

This keeps the action compatible with connectors built against any baton-sdk version (trait-only, resource-only, or both).

Validation

Verified the jq logic against all shapes:

Scenario Result
New SDK: resource DISABLED, trait defaulted ENABLED STATUS_DISABLED ✅ (was STATUS_ENABLED ❌)
New SDK: resource ENABLED, trait defaulted ENABLED STATUS_ENABLED
Old connector: trait DISABLED, no resource status STATUS_DISABLED
Old connector: trait ENABLED, no resource status STATUS_ENABLED
Resource UNSPECIFIED + trait DISABLED STATUS_DISABLED
Nothing set unknown

bash -n passes on the script.

🤖 Generated with Claude Code

…ust deprecated trait

The account-status-lifecycle-test read user status only from the deprecated
UserTrait annotation (`UserTrait_Status_Status`). In baton-sdk versions that
moved status to a resource-level attribute (`Status_ResourceStatus`), a
connector that sets only the resource-level status leaves the trait status
unset, and the SDK defaults an unset trait status to STATUS_ENABLED. As a
result the test always read STATUS_ENABLED and disable verifications failed
even when the account was correctly disabled.

get_user_status now reads both locations, prefers the resource-level value
(normalized from RESOURCE_STATUS_* to the trait form STATUS_*), and falls back
to the trait value only when no resource-level status is present. This keeps
the action compatible with connectors built against any baton-sdk version.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@luisina-santos
luisina-santos requested a review from a team July 21, 2026 16:49
Comment thread actions/account-status-lifecycle-test/account-status-lifecycle-test.sh Outdated
…esource

Addresses review feedback: explicitly call out that baton-sdk v0.19.0
(ConductorOne/baton-sdk#996) is where status moved from the deprecated
UserTrait field to the resource-level attribute.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

@ggreer ggreer left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Oops. Whenever baton-sdk is upgraded in all the connector repos, we can simplify this.

@luisina-santos
luisina-santos merged commit e4ee4fb into main Jul 22, 2026
2 checks passed
@luisina-santos
luisina-santos deleted the luisinasantos/status-lifecycle-test-resource-status branch July 22, 2026 18:14
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.

4 participants