Fix query UTxO rendering - #1399
Merged
Merged
Conversation
palas
requested review from
Jimbo4350,
carbolymer,
disassembler,
kevinhammond and
newhoggy
as code owners
July 25, 2026 00:55
Contributor
There was a problem hiding this comment.
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
NoDatumwhen 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
approved these changes
Jul 27, 2026
Jimbo4350
left a comment
Contributor
There was a problem hiding this comment.
LGTM, one minor comment.
carbolymer
reviewed
Jul 27, 2026
carbolymer
approved these changes
Jul 27, 2026
…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
force-pushed
the
1398-fix-query-utxo-rendering
branch
from
July 27, 2026 21:21
d5fab0f to
c3f4243
Compare
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
enabled auto-merge
July 27, 2026 21:48
palas
disabled auto-merge
July 27, 2026 21:48
palas
force-pushed
the
1398-fix-query-utxo-rendering
branch
from
July 27, 2026 21:52
8be7f1c to
c3f4243
Compare
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
cardano-cli latest query utxo --output-textrenders 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 aNoDatumtag 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
.changes/