Skip to content

Commit 8794769

Browse files
authored
backport 5.2 reprocess do not fail on missing payload (#2247)
* do not fail on missing payload (#2245) * release notes * fix indentation
1 parent 3c83b39 commit 8794769

File tree

3 files changed

+42
-3
lines changed

3 files changed

+42
-3
lines changed

docs/pages/release_notes.rst

Lines changed: 20 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.2.3)
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.2.2...v5.2.3
15+
616
************************
717
Hazelnut update (v5.2.2)
818
************************
@@ -40,6 +50,16 @@ Release date: 2023-04-25
4050

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

53+
************************
54+
Hazelnut update (v5.1.2)
55+
************************
56+
57+
Release date: 2023-06-13
58+
59+
- Fixed issue where a Reprocess failed due to missing data
60+
61+
**Full Changelog**: https://github.com/nuts-foundation/nuts-node/compare/v5.1.1...v5.1.2
62+
4363
************************
4464
Hazelnut update (v5.1.1)
4565
************************

network/network.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -740,8 +740,8 @@ func (n *Network) Reprocess(ctx context.Context, contentType string) (*Reprocess
740740
// add to Nats
741741
subject := fmt.Sprintf("%s.%s", events.ReprocessStream, contentType)
742742
payload, err := n.state.ReadPayload(ctx, tx.PayloadHash())
743-
if err != nil {
744-
return nil, fmt.Errorf("reprocess abort on transaction %#x payload %#x: %w", tx.Ref(), tx.PayloadHash(), err)
743+
if err != nil && !errors.Is(err, dag.ErrPayloadNotFound) {
744+
return nil, fmt.Errorf("reprocess abort on transaction %s payload %s: %w", tx.Ref(), tx.PayloadHash(), err)
745745
}
746746
twp := events.TransactionWithPayload{
747747
Transaction: tx,
@@ -754,7 +754,7 @@ func (n *Network) Reprocess(ctx context.Context, contentType string) (*Reprocess
754754
Trace("Publishing transaction")
755755
_, err = js.PublishAsync(subject, data)
756756
if err != nil {
757-
return nil, fmt.Errorf("reprocess abort on transaction %#x publish: %w", tx.Ref(), err)
757+
return nil, fmt.Errorf("reprocess abort on transaction %s publish: %w", tx.Ref(), err)
758758
}
759759
}
760760

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)