Skip to content

Commit c303cca

Browse files
authored
backport 5.1 reprocess do not fail on missing payload (#2246)
* do not fail on missing payload (#2245) * release notes
1 parent d8b2b9f commit c303cca

File tree

3 files changed

+32
-3
lines changed

3 files changed

+32
-3
lines changed

docs/pages/release_notes.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@ Release notes
55

66
What has been changed, and how to update between versions.
77

8+
************************
9+
Hazelnut update (v5.1.2)
10+
************************
11+
12+
Release date: 2023-06-13
13+
14+
- Fixed issue where a Reprocess failed due to missing data
15+
16+
**Full Changelog**: https://github.com/nuts-foundation/nuts-node/compare/v5.1.1...v5.1.2
17+
818
************************
919
Hazelnut update (v5.1.1)
1020
************************

network/network.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -760,8 +760,8 @@ func (n *Network) Reprocess(ctx context.Context, contentType string) (*Reprocess
760760
// add to Nats
761761
subject := fmt.Sprintf("%s.%s", events.ReprocessStream, contentType)
762762
payload, err := n.state.ReadPayload(ctx, tx.PayloadHash())
763-
if err != nil {
764-
return nil, fmt.Errorf("reprocess abort on transaction %#x payload %#x: %w", tx.Ref(), tx.PayloadHash(), err)
763+
if err != nil && !errors.Is(err, dag.ErrPayloadNotFound) {
764+
return nil, fmt.Errorf("reprocess abort on transaction %s payload %s: %w", tx.Ref(), tx.PayloadHash(), err)
765765
}
766766
twp := events.TransactionWithPayload{
767767
Transaction: tx,
@@ -774,7 +774,7 @@ func (n *Network) Reprocess(ctx context.Context, contentType string) (*Reprocess
774774
Trace("Publishing transaction")
775775
_, err = js.PublishAsync(subject, data)
776776
if err != nil {
777-
return nil, fmt.Errorf("reprocess abort on transaction %#x publish: %w", tx.Ref(), err)
777+
return nil, fmt.Errorf("reprocess abort on transaction %s publish: %w", tx.Ref(), err)
778778
}
779779
}
780780

network/network_test.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -782,6 +782,25 @@ func TestNetwork_Reprocess(t *testing.T) {
782782
assert.Equal(t, 0, counter)
783783
})
784784

785+
t.Run("missing payload", func(t *testing.T) {
786+
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
787+
defer cancel()
788+
789+
setup, eventManager := newSetup(t)
790+
setup.state.EXPECT().FindBetweenLC(gomock.Any(), uint32(0), uint32(1000)).Return([]dag.Transaction{tx}, nil)
791+
setup.state.EXPECT().ReadPayload(gomock.Any(), tx.PayloadHash()).Return(nil, dag.ErrPayloadNotFound)
792+
var counter int
793+
wg := sync.WaitGroup{}
794+
wg.Add(1)
795+
796+
subscribe(ctx, t, eventManager, &wg, &counter)
797+
798+
_, err := setup.network.Reprocess(ctx, "application/did+json")
799+
require.NoError(t, err)
800+
wg.Wait()
801+
assert.Equal(t, 1, counter)
802+
})
803+
785804
t.Run("error", func(t *testing.T) {
786805
t.Run("query", func(t *testing.T) {
787806
ctx, cancel := context.WithTimeout(context.Background(), time.Second)

0 commit comments

Comments
 (0)