Skip to content

der reindex masks per-object decode errors (exits success, writes index) + error was nil! printing bug #260

@sfriedenberg-etsy

Description

@sfriedenberg-etsy

Problem

der reindex collected a per-object decode error (---: malformed value on the konfig) into its objects with errors: block but then proceeded to write the index (16 pages), recompile konfig, and exit as if successful. The error was easy to miss amid the success log lines, and the exit status did not reflect the failure.

reindex.go (internal/oscar/store/reindex.go) collects errors into the objectsWithErrors map and prints them, but Reindex returns err, which by that point is nil (the per-object errors were stored in the map, not propagated). So the command surfaces errors only as printed text, not as a non-zero exit, and continues to rewrite the index.

Latent printing bug

In the error-printing loop (reindex.go ~line 100):

for _, objectWithError := range objectsWithErrors {
    ui.CLIErrorTreeEncoder.EncodeTo(err, store.envRepo.GetUI())   // <-- outer `err` (nil), not objectWithError.error

It encodes the outer err (nil at that point) instead of objectWithError.error. This is why the reindex output contains the literal line error was nil!.

Desired

  1. reindex returns non-zero / surfaces a clear aggregate failure when any object errored.
  2. the error-printing loop encodes objectWithError.error, not the outer nil err.

Verify

BATS: reindex over a store with a known-bad object asserts non-zero exit and that the specific object error is printed (not error was nil!).


:clown: filed by Clown (0.4.0+cd38c2d) — built from cd38c2d

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions