Skip to content

fix: include line number in std.trace output - #1101

Merged
stephenamar-db merged 1 commit into
databricks:masterfrom
He-Pin:fix/trace-line-number
Jul 30, 2026
Merged

fix: include line number in std.trace output#1101
stephenamar-db merged 1 commit into
databricks:masterfrom
He-Pin:fix/trace-line-number

Conversation

@He-Pin

@He-Pin He-Pin commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Summary

  • std.trace now outputs TRACE: <file>:<line> <msg> instead of TRACE: <file> <msg>
  • Aligns with go-jsonnet, jrsonnet, C++ jsonnet, and the official documentation example
  • Uses the existing EvalErrorScope.prettyIndex infrastructure to resolve line numbers

Motivation

All other Jsonnet implementations include the line number in trace output:

  • go-jsonnet: TRACE: test.jsonnet:3 hello
  • jrsonnet: TRACE: test.jsonnet:3 hello
  • C++ jsonnet: TRACE: test.jsonnet:3 hello
  • Official docs: TRACE: test.jsonnet:3 cond is true returning {"b": true}

sjsonnet was the only implementation omitting it, making trace output less useful for debugging.

Test plan

  • Updated golden files for trace.jsonnet, comprehension_no_unsafe_hoist_trace.jsonnet, lazy_array_reverse_cache_trace.jsonnet
  • Updated EvaluatorTests trace assertions
  • Full test suite passes (sjsonnet.jvm.2_13_18.test)

Motivation:
std.trace output was missing the line number, diverging from all other
Jsonnet implementations (go-jsonnet, jrsonnet, C++ jsonnet) which all
emit "TRACE: <file>:<line> <msg>". sjsonnet only emitted "TRACE: <file> <msg>".

Modification:
Use the existing EvalErrorScope.prettyIndex infrastructure to resolve the
position offset to a line number and include it in the trace output format.

Result:
std.trace now outputs "TRACE: <file>:<line> <msg>", consistent with the
official documentation example and all reference implementations.
@stephenamar-db
stephenamar-db merged commit 1f5805a into databricks:master Jul 30, 2026
5 checks passed
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.

2 participants