Commit e4ee4fb
fix(account-status-lifecycle-test): read resource-level status for SDK compatibility (#102)
## 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](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>1 parent e8c2e04 commit e4ee4fb
2 files changed
Lines changed: 39 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
117 | 117 | | |
118 | 118 | | |
119 | 119 | | |
120 | | - | |
121 | | - | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
122 | 125 | | |
123 | 126 | | |
124 | 127 | | |
| |||
Lines changed: 34 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
44 | 60 | | |
45 | 61 | | |
46 | | - | |
| 62 | + | |
47 | 63 | | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
58 | 81 | | |
59 | 82 | | |
60 | 83 | | |
| |||
0 commit comments