fix(postprocessing): ignore UploadReady events without an upload

The posix storage publishes UploadReady with an empty UploadID when it
assimilates a file it found on disk. There is no upload session behind
such an event, so the lookup in the upload store failed with
"nats: invalid key" and logged two errors per file.

Skip these events, like PostprocessingStepFinished already does for
on demand scans.
This commit is contained in:
Dominik Schmidt committed 2026-11-12 00:47:54 +01:00
1 parent 9347da7c9c
commit ade9daa863
2 files changed
+33

No files matched your search

@@ -267,6 +267,9 @@ func (pps *PostprocessingService) processEvent(e raw.Event) error {
})
case events.UploadReady:
pps.log.Debug().Str("UploadID", e.ID).Str("filename", ev.Filename).Msg("processing UploadReady")
if ev.UploadID == "" {
return nil
}
// the upload failed - let's keep it around for a while - but mark it as finished
pp, err = pps.getPP(pps.store, ev.UploadID)
if err != nil {
@@ -197,4 +197,34 @@ var _ = Describe("PostprocessingService", func() {
Expect(errors.Is(err, ErrFatal)).To(BeFalse())
})
})
Describe("handling UploadReady", func() {
uploadReady := func(uploadID string) raw.Event {
ev := events.UploadReady{
UploadID: uploadID,
Filename: "test.txt",
}
return raw.Event{
Event: events.Event{
ID: uuid.New().String(),
Type: reflect.TypeOf(ev).String(),
Event: ev,
},
}
}
It("ignores an event that does not belong to an upload", func() {
pps = newService()
Expect(pps.processEvent(uploadReady(""))).To(Succeed())
})
It("fails for an upload it does not know", func() {
pps = newService()
err := pps.processEvent(uploadReady("upload-" + uuid.New().String()))
Expect(err).To(HaveOccurred())
Expect(errors.Is(err, ErrEvent)).To(BeTrue())
})
})
})