Skip to content

Fix query UTxO rendering - #1399

Merged
palas merged 3 commits into
masterfrom
1398-fix-query-utxo-rendering
Jul 28, 2026
Merged

Fix query UTxO rendering#1399
palas merged 3 commits into
masterfrom
1398-fix-query-utxo-rendering

Conversation

@palas

@palas palas commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Context

cardano-cli latest query utxo --output-text renders a dangling + separator after the lovelace amount for pre-Babbage era outputs with nothing after it. See #1398.

This PR removes the + for pre Alonzo eras. And it adds a NoDatum tag when it is not present for Alonzo onwards. It also adds the hash for Alonzo, which was ignored before, and golden tests exercising the 3 cases.

How to trust this PR

The actual changes are very small, and they are very type driven. Also this PR includes golden tests.

Checklist

  • Commit sequence broadly makes sense and commits have useful messages
  • New tests are added if needed and existing tests are updated. See Running tests for more details
  • Self-reviewed the diff
  • Changelog fragment added in .changes/

@palas palas self-assigned this Jul 25, 2026
Copilot AI review requested due to automatic review settings July 25, 2026 00:55

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes cardano-cli latest query utxo --output-text formatting so pre-Alonzo outputs no longer render a dangling " + " after the value, and Alonzo+ outputs consistently render an explicit datum marker/hash (matching the Babbage+ style). This aligns the text output with expected script-parsing stability and adds golden coverage for the key era cases referenced in issue #1398.

Changes:

  • Suppress the datum separator entirely for pre-Alonzo eras by only emitting " + " when a datum rendering exists.
  • Render Alonzo-era datum hashes (and NoDatum when absent) to match the Babbage+ ledger-style datum rendering.
  • Add golden tests and fixtures covering Shelley (no datums), Alonzo (no datum + datum hash), and Conway (no datum + datum hash + inline datum).

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
cardano-cli/src/Cardano/CLI/EraBased/Query/Run.hs Adjusts UTxO text rendering to avoid dangling separators pre-Alonzo and to render datum info consistently for Alonzo+.
cardano-cli/test/cardano-cli-golden/Test/Golden/Query/UTxO.hs Adds golden tests constructing era-specific UTxOs to validate the text renderer across Shelley/Alonzo/Conway cases.
cardano-cli/test/cardano-cli-golden/files/golden/shelley/query-utxo-text.out New golden output fixture ensuring Shelley-era lines end at the value (no trailing " + ").
cardano-cli/test/cardano-cli-golden/files/golden/alonzo/query-utxo-text.out New golden output fixture validating NoDatum and DatumHash rendering for Alonzo.
cardano-cli/test/cardano-cli-golden/files/golden/conway/query-utxo-text.out New golden output fixture validating NoDatum, DatumHash, and inline datum rendering for Conway.
cardano-cli/cardano-cli.cabal Registers the new golden test module in the cardano-cli-golden test-suite.
.changes/20260724_233532_cardano-cli_pablo.lamela_fix_query_utxo_text_dangling_separator.yml Adds changelog entry for the bugfix + golden test addition.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Jimbo4350 Jimbo4350 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, one minor comment.

Comment thread cardano-cli/src/Cardano/CLI/EraBased/Query/Run.hs
Comment thread cardano-cli/src/Cardano/CLI/EraBased/Query/Run.hs Outdated
palas added 2 commits July 27, 2026 23:21
…pre-Babbage eras

The datum shown after each output's value was rendered through
`datumTxOutL`, which only exists from Babbage onwards, so outputs of
older eras ended in a dangling " + " separator with nothing after it.

Outputs of eras without datums (Shelley to Mary) now end at the value.
Alonzo era outputs, which can carry a datum hash, now render it the
same way the Babbage+ ledger datum is rendered (previously the hash
was silently dropped).

The era dispatch uses `forEraInEon` instead of the deprecated
closed-range eliminator (matching #1397), so future eras like Dijkstra
take the babbage+ branch instead of hitting the eliminator's
"TODO Dijkstra" error.

Fixes #1398
Cover a datum-less Shelley era output (regression test for #1398), an
Alonzo era output with and without a datum hash, and Conway era outputs
without a datum, with a datum hash and with an inline datum.

`filteredUTxOsToText` is now exported so the tests can render
hand-built UTxO sets without a node.
@palas
palas force-pushed the 1398-fix-query-utxo-rendering branch from d5fab0f to c3f4243 Compare July 27, 2026 21:21
palas added a commit that referenced this pull request Jul 27, 2026
Address review comments on PR #1399:

* Drop the `forall era` from `utxoToText` and the type annotation that
  needed it: applying `show` to the result of the inner `forEraInEon`
  (instead of inside each of its branches) lets the datum type be
  inferred from the babbage+ branch.
* Render the alonzo datum hash pointfree with `strictMaybe`.

No behaviour change: the golden files are unchanged.
@palas
palas enabled auto-merge July 27, 2026 21:48
@palas
palas disabled auto-merge July 27, 2026 21:48
@palas
palas force-pushed the 1398-fix-query-utxo-rendering branch from 8be7f1c to c3f4243 Compare July 27, 2026 21:52
Address a review comment on PR #1399: write the datum hash rendering
pointfree instead of case-matching on the `StrictMaybe`.

The `forall era` on `utxoToText` stays: the type annotation it enables
is what fixes the era of the `Datum` being rendered, since neither
`NoDatum` nor `DatumHash` mentions it.

No behaviour change: the golden files are unchanged.
@palas
palas enabled auto-merge July 27, 2026 23:59
@palas
palas added this pull request to the merge queue Jul 28, 2026
Merged via the queue into master with commit 2c3376c Jul 28, 2026
25 checks passed
@palas
palas deleted the 1398-fix-query-utxo-rendering branch July 28, 2026 00:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] - query utxo --output-text renders dangling "+ " after value for pre-Babbage outputs

4 participants