fix: preserve site coordinates and redacted secrets #2
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/site-organization-apply"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Decode site responses from the API data envelope and preserve configured SNMP communities when the API redacts them. Document the drift-detection limitation.
Verification: Go tests, vet and module verification; site/organization Terraform acceptance tests; OpenTofu create, update and no-change refresh against an API-contract fixture.
🤖 Skippy PR review
1 finding — 1 blocking before merge.
internal/provider/client.go:153Reviewed
9e5594282850. Commentskippy reviewto re-run.@ -151,2 +151,3 @@var result Sitevar result struct {Data Site `json:"data"`🟠 High — Envelope decode fixed for sites only: 24 other decodes still read bare structs
The API wraps every JSON success in
%{data: ...}(Resources.success_body/2, and theResourceControllermoduledoc calls it the whole v1 contract), so these three site decodes are the only ones in this file that now match the wire format. The other 24var result <Struct>unmarshals in this file (device, schedule, escalation policy, agent, integration, maintenance window, check, coverage) still decode the envelope into a bare struct, which succeeds silently and leaves every field zero.GetDeviceis the sharp edge:DeviceResource.Createthen writesdata.IPAddress = types.StringValue(created.IPAddress), so a real apply plansip_address = "192.0.2.10"and stores"", and Terraform rejects it with "Provider produced inconsistent result after apply". The device, check and coverage tests miss this because their httptest mocks still return bare structs, the same false negativeclient_test.gowas fixed for here. Suggested fix: onetype apiEnvelope[T any] struct { Data Tjson:"data"}(go 1.25), decode into it in every method in this file, decode into*Tso a null or missingdataerrors instead of yielding a zero resource, and wrap the mocks in the affected_test.gofiles the same way.Auto-fix pushed by skippy-bot in
91f884de.Still open, not mechanical: none.
Not re-reviewed: this repair came from the reviewer's own findings, so the fix pass closes what it fixed and CI is the referee.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.