[Secrets] UI reports a saved rotate/delete as failed when the audit write throws (cache not cleared) #34
Reference in New Issue
Block a user
Delete Branch "%!s()"
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?
From the scadaproj#15 shared-library review (
code-reviews/Secrets/findings.md, Secrets-013), verified at91fb2b4. Update the finding's Resolution row when fixed.ZB.MOM.WW.Secrets/src/ZB.MOM.WW.Secrets.Ui/Components/SecretEditor.razor:138(alsoConfirmDeleteModal.razor:91)Description
In
SecretEditor.SubmitAsync,Store.UpsertAsync(line 138) and the successAudit.WriteAsync(lines 140–151) sit inside the sametry. Itscatch (Exception)(lines 155–163) treats any throw as a failed mutation:_error = "Unable to add/rotate the secret.";saved == false, so theISecretCacheInvalidator.InvalidateandOnSavedblock (lines 170–178) is skipped.ConfirmDeleteModal.ConfirmAsynchas the identical shape:DeleteAsyncat line 91, audit at lines 93–104, catch at lines 108–114, and eviction skipped at lines 121–126. No UI test makes the audit writer throw;CapturingAuditWriternever fails.Failure scenario
The audit sink (for example a SQL-backed
IAuditWriter) is briefly unavailable. An operator rotatesdb/centralto revoke a leaked credential.secret.rotate/ Failure.The operator may retry, creating a second revision, or believe the secret is unchanged. A delete behaves the same way: the secret is tombstoned, yet it is reported as not deleted and keeps resolving from cache.
Recommendation
Move the success audit out of the mutation
try. Once the store write returns, setsaved = trueand invalidate the cache. Then write the success audit in its own best-effort try/catch, and log when it fails. Add bUnit tests with a throwingIAuditWriterfor both components.Resolution
Unresolved.
Fixed on main 051bdb6 (Secrets-013 → Resolved): SecretEditor and ConfirmDeleteModal run the success audit after the store write, best-effort — an audit failure is a logged warning (never the value), the UI reports the committed change as saved and the cache is evicted. Evidence: Secrets solution (5 test projects) all pass — Core 246 (1 DPAPI skip), SqlServer 60 (16 live-SQL skips), Akka 44, Grpc 196, Ui 20; each regression test fails with its fix removed. Ships in Secrets 0.6.6 (unpublished).