Skip to content

test: pin the fence read-error path-strip with a positive unit test #4191

Description

@Job28703

Context

From the review of #4127 (head 2fb24a89), commit fix(coordination): stabilize fence read errors:

loadLegacyCoordinationWriterFence now strips the trailing quoted absolute path from read-failure reason (legacy_writer_fence.ts:145-152):

const path = (error as NodeJS.ErrnoException).path;
const reason = error instanceof Error ? error.message : "legacy writer fence read failed";
// ...
reason: typeof path === "string" ? reason.replace(` '${path}'`, "") : reason,

Problem

The strip is a string-suffix match against Node's current fs error message format. The parity fixture (tests/fixtures/control_plane/legacy_writer_fence_caller_parity_v0.json:136) pins the path-free expectation, but nothing constructs a real fs error carrying error.path and asserts the strip actually fired. If Node ever changes its message shape (unquoted path, double quotes, path mid-message), the strip silently stops working and absolute local paths leak back into public reason — with no test going red.

Suggested fix

One focused unit test: construct an ENOENT-shaped error whose .path is a temp absolute path and whose .message ends with '<path>'; call the reader; assert reason contains no path fragment. A negative arm (error without path) asserting the message is preserved unchanged would also cover the defensive branch.

Non-blocking follow-up from #4127 (comment).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions