Skip to content

Commit

Permalink
backport 5.3 reprocess do not fail on missing payload (#2248)
Browse files Browse the repository at this point in the history
* do not fail on missing payload (#2245)

* release notes
  • Loading branch information
gerardsn authored Jun 13, 2023
1 parent 4db689b commit ff5ac79
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 3 deletions.
30 changes: 30 additions & 0 deletions docs/pages/release_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@
Release notes
#############

************************
Hazelnut update (v5.3.1)
************************

Release date: 2023-06-13

- Fixed issue where a Reprocess failed due to missing data

**Full Changelog**: https://github.com/nuts-foundation/nuts-node/compare/v5.3.0...v5.3.1

************************
Hazelnut update (v5.3.0)
************************
Expand All @@ -22,6 +32,16 @@ Release date: 2023-05-26

**Full Changelog**: https://github.com/nuts-foundation/nuts-node/compare/v5.2.0...v5.3.0

************************
Hazelnut update (v5.2.3)
************************

Release date: 2023-06-13

- Fixed issue where a Reprocess failed due to missing data

**Full Changelog**: https://github.com/nuts-foundation/nuts-node/compare/v5.2.2...v5.2.3

************************
Hazelnut update (v5.2.2)
************************
Expand Down Expand Up @@ -58,6 +78,16 @@ Release date: 2023-04-25

**Full Changelog**: https://github.com/nuts-foundation/nuts-node/compare/v5.1.0...v5.2.0

************************
Hazelnut update (v5.1.2)
************************

Release date: 2023-06-13

- Fixed issue where a Reprocess failed due to missing data

**Full Changelog**: https://github.com/nuts-foundation/nuts-node/compare/v5.1.1...v5.1.2

************************
Hazelnut update (v5.1.1)
************************
Expand Down
6 changes: 3 additions & 3 deletions network/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -784,8 +784,8 @@ func (n *Network) Reprocess(ctx context.Context, contentType string) (*Reprocess
// add to Nats
subject := fmt.Sprintf("%s.%s", events.ReprocessStream, contentType)
payload, err := n.state.ReadPayload(ctx, tx.PayloadHash())
if err != nil {
return nil, fmt.Errorf("reprocess abort on transaction %#x payload %#x: %w", tx.Ref(), tx.PayloadHash(), err)
if err != nil && !errors.Is(err, dag.ErrPayloadNotFound) {
return nil, fmt.Errorf("reprocess abort on transaction %s payload %s: %w", tx.Ref(), tx.PayloadHash(), err)
}
twp := events.TransactionWithPayload{
Transaction: tx,
Expand All @@ -798,7 +798,7 @@ func (n *Network) Reprocess(ctx context.Context, contentType string) (*Reprocess
Trace("Publishing transaction")
_, err = js.PublishAsync(subject, data)
if err != nil {
return nil, fmt.Errorf("reprocess abort on transaction %#x publish: %w", tx.Ref(), err)
return nil, fmt.Errorf("reprocess abort on transaction %s publish: %w", tx.Ref(), err)
}
}

Expand Down
19 changes: 19 additions & 0 deletions network/network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -879,6 +879,25 @@ func TestNetwork_Reprocess(t *testing.T) {
assert.Equal(t, 0, counter)
})

t.Run("missing payload", func(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
defer cancel()

setup, eventManager := newSetup(t)
setup.state.EXPECT().FindBetweenLC(gomock.Any(), uint32(0), uint32(1000)).Return([]dag.Transaction{tx}, nil)
setup.state.EXPECT().ReadPayload(gomock.Any(), tx.PayloadHash()).Return(nil, dag.ErrPayloadNotFound)
var counter int
wg := sync.WaitGroup{}
wg.Add(1)

subscribe(ctx, t, eventManager, &wg, &counter)

_, err := setup.network.Reprocess(ctx, "application/did+json")
require.NoError(t, err)
wg.Wait()
assert.Equal(t, 1, counter)
})

t.Run("error", func(t *testing.T) {
t.Run("query", func(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
Expand Down

0 comments on commit ff5ac79

Please sign in to comment.