Skip to content

Commit ff5ac79

Browse files
authored
backport 5.3 reprocess do not fail on missing payload (#2248)
* do not fail on missing payload (#2245) * release notes
1 parent 4db689b commit ff5ac79

File tree

3 files changed

+52
-3
lines changed

3 files changed

+52
-3
lines changed

docs/pages/release_notes.rst

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,16 @@
33
Release notes
44
#############
55

6+
************************
7+
Hazelnut update (v5.3.1)
8+
************************
9+
10+
Release date: 2023-06-13
11+
12+
- Fixed issue where a Reprocess failed due to missing data
13+
14+
**Full Changelog**: https://github.com/nuts-foundation/nuts-node/compare/v5.3.0...v5.3.1
15+
616
************************
717
Hazelnut update (v5.3.0)
818
************************
@@ -22,6 +32,16 @@ Release date: 2023-05-26
2232

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

35+
************************
36+
Hazelnut update (v5.2.3)
37+
************************
38+
39+
Release date: 2023-06-13
40+
41+
- Fixed issue where a Reprocess failed due to missing data
42+
43+
**Full Changelog**: https://github.com/nuts-foundation/nuts-node/compare/v5.2.2...v5.2.3
44+
2545
************************
2646
Hazelnut update (v5.2.2)
2747
************************
@@ -58,6 +78,16 @@ Release date: 2023-04-25
5878

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

81+
************************
82+
Hazelnut update (v5.1.2)
83+
************************
84+
85+
Release date: 2023-06-13
86+
87+
- Fixed issue where a Reprocess failed due to missing data
88+
89+
**Full Changelog**: https://github.com/nuts-foundation/nuts-node/compare/v5.1.1...v5.1.2
90+
6191
************************
6292
Hazelnut update (v5.1.1)
6393
************************

network/network.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -784,8 +784,8 @@ func (n *Network) Reprocess(ctx context.Context, contentType string) (*Reprocess
784784
// add to Nats
785785
subject := fmt.Sprintf("%s.%s", events.ReprocessStream, contentType)
786786
payload, err := n.state.ReadPayload(ctx, tx.PayloadHash())
787-
if err != nil {
788-
return nil, fmt.Errorf("reprocess abort on transaction %#x payload %#x: %w", tx.Ref(), tx.PayloadHash(), err)
787+
if err != nil && !errors.Is(err, dag.ErrPayloadNotFound) {
788+
return nil, fmt.Errorf("reprocess abort on transaction %s payload %s: %w", tx.Ref(), tx.PayloadHash(), err)
789789
}
790790
twp := events.TransactionWithPayload{
791791
Transaction: tx,
@@ -798,7 +798,7 @@ func (n *Network) Reprocess(ctx context.Context, contentType string) (*Reprocess
798798
Trace("Publishing transaction")
799799
_, err = js.PublishAsync(subject, data)
800800
if err != nil {
801-
return nil, fmt.Errorf("reprocess abort on transaction %#x publish: %w", tx.Ref(), err)
801+
return nil, fmt.Errorf("reprocess abort on transaction %s publish: %w", tx.Ref(), err)
802802
}
803803
}
804804

network/network_test.go

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

882+
t.Run("missing payload", func(t *testing.T) {
883+
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
884+
defer cancel()
885+
886+
setup, eventManager := newSetup(t)
887+
setup.state.EXPECT().FindBetweenLC(gomock.Any(), uint32(0), uint32(1000)).Return([]dag.Transaction{tx}, nil)
888+
setup.state.EXPECT().ReadPayload(gomock.Any(), tx.PayloadHash()).Return(nil, dag.ErrPayloadNotFound)
889+
var counter int
890+
wg := sync.WaitGroup{}
891+
wg.Add(1)
892+
893+
subscribe(ctx, t, eventManager, &wg, &counter)
894+
895+
_, err := setup.network.Reprocess(ctx, "application/did+json")
896+
require.NoError(t, err)
897+
wg.Wait()
898+
assert.Equal(t, 1, counter)
899+
})
900+
882901
t.Run("error", func(t *testing.T) {
883902
t.Run("query", func(t *testing.T) {
884903
ctx, cancel := context.WithTimeout(context.Background(), time.Second)

0 commit comments

Comments
 (0)