Skip to content

fix: assertion plan-time validation, devhelm_secret data source, alert-channel drift detection - #36

Merged
caballeto merged 1 commit into
mainfrom
fix/assertion-validator-secret-ds-drift
Jun 11, 2026
Merged

fix: assertion plan-time validation, devhelm_secret data source, alert-channel drift detection#36
caballeto merged 1 commit into
mainfrom
fix/assertion-validator-secret-ds-drift

Conversation

@caballeto

Copy link
Copy Markdown
Member

Summary

Three confirmed bugs fixed:

1. Assertion config plan-time validation

assertions[].config is a JSON string — users write jsonencode({expected = 200}) but the API expects "200" (string). Previously this planned cleanly but failed at apply with "Provider produced inconsistent result." Now validateAssertionConfigJSON decodes against the generated per-assertion-type structs at plan time, catching type mismatches, unknown keys, and missing required fields before apply.

2. devhelm_secret data source

New data source for looking up secrets by key name (users previously had to hardcode UUIDs). Returns id, key, value_hash — never the plaintext value.

3. Alert-channel config drift detection

Read() now compares the server's configHash against the stored state hash. On divergence, it preserves the old hash and nulls the write-only config attributes so the next terraform plan shows a diff and Update re-pushes the HCL-declared config.

Test plan

  • go build ./... — clean
  • go vet ./... — clean
  • go test ./... — all packages pass
  • 11 new assertion-validator unit tests
  • Secret data source unit tests (mapping + key lookup)
  • Drift-helper unit test
  • Acceptance tests (require real API, run separately)

Made with Cursor

…t-channel drift detection

- Add validateAssertionConfigJSON: decodes each assertion's `config` JSON
  against the generated per-type struct at plan time, catching value-type
  mismatches (e.g. numeric `expected` where the API wants a string), typos,
  case-mismatched keys, and missing required fields — instead of failing
  apply with "Provider produced inconsistent result".
- Add devhelm_secret data source: look up secrets by key (List + filter),
  returning id, key, and value_hash (never the plaintext value).
- Detect out-of-band alert-channel config drift in Read: when the server's
  configHash diverges from state, preserve the stored hash and null the
  write-only config attrs (via clearAlertChannelConfigAttrs) so the next
  plan shows a diff and Update re-pushes the declared config.

Co-authored-by: Cursor <cursoragent@cursor.com>
@caballeto
caballeto merged commit 0cc5c32 into main Jun 11, 2026
6 checks passed
@caballeto
caballeto deleted the fix/assertion-validator-secret-ds-drift branch June 11, 2026 12:34
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.

1 participant