Skip to content

Commit

Permalink
feat: ignore idempotency hash from old data
Browse files Browse the repository at this point in the history
  • Loading branch information
gfyrag committed Oct 23, 2024
1 parent 79fa355 commit 7a23797
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
8 changes: 6 additions & 2 deletions internal/controller/ledger/log_process.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,12 @@ func forgeLog[INPUT any, OUTPUT ledger.LogPayload](ctx context.Context, store St
return nil, err
}
if err == nil {
if computedHash := ledger.ComputeIdempotencyHash(parameters.Input); log.IdempotencyHash != computedHash {
return nil, newErrInvalidIdempotencyInputs(log.IdempotencyKey, log.IdempotencyHash, computedHash)
// notes(gfyrag): idempotency hash should never be empty in this case, but data from previous
// ledger version does not have this field and it cannot be recomputed
if log.IdempotencyHash != "" {
if computedHash := ledger.ComputeIdempotencyHash(parameters.Input); log.IdempotencyHash != computedHash {
return nil, newErrInvalidIdempotencyInputs(log.IdempotencyKey, log.IdempotencyHash, computedHash)
}
}

return pointer.For(log.Data.(OUTPUT)), nil
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
--todo: add special traitement on code when value is empty
alter table "{{.Bucket}}".logs
add column idempotency_hash bytea;

0 comments on commit 7a23797

Please sign in to comment.