Avoid duplicated paths in FileIOError messages

Open Beginner friendly
#1,434 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
haskell
Domain
backend

Research direction

The issue identifies the renderer in Cardano.Api.Error and asks for coverage of both an IOException that includes the path and one without a filename. Read that renderer and its existing tests first, then check how the underlying exception exposes its filename. Done when messages retain the operation and reason, show the path once when present, and keep the wrapper path when absent.

Written by the indexing model from the issue text.

Description

FileIOError messages can repeat the same path because the wrapped IOException already includes it. The current renderer in Cardano.Api.Error prepends the wrapper's path unconditionally:

FileIOError path ioe ->
  pretty path <> ": " <> pretty (displayException ioe)

For example, the cardano-cli review reports:

Error: p: p: withBinaryFile: does not exist (No such file or directory)

The path should appear once, while retaining the operation and failure reason. The fix should also preserve the wrapper's path when the underlying exception has no filename. Add coverage for both cases.

This is existing behavior in shared file-error rendering, surfaced again as cardano-cli reuses the API's file IO helpers in cardano-cli PR #1515. Track the rendering fix in a separate cardano-api PR; it does not need to block that CLI change.

Original review comment: https://github.com/IntersectMBO/cardano-cli/pull/1515#discussion_r4773037387

Dominant language
Haskell
Stars
41
Forks
33
Avg merge
3d 3h
Merged PRs (30d)
15

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from IntersectMBO/cardano-api

All issues in IntersectMBO/cardano-api

Similar issues

More Haskell issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.