google / google/jsonnet

[feature request] Hide std.jsonnet in tracebacks

Open
#673 1 comment 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Jsonnet
Stars
7.6k
Forks
475
PR merge metrics
No merged PRs in 30d

Description

Many of the functions in the stdlib result in a large number of stack frames.

In some circumstances, usage of foldl, comprehensions, etc, can cause the vast majority of a large stack trace to be std.jsonnet frames only.

In one example we've encountered, the stack trace looked like so:

```
std.jsonnet:731:15-42 thunk
std.jsonnet:736:27-30 thunk
std.jsonnet:560:22-25 thunk
std.jsonnet:36:17
std.jsonnet:36:8-19 thunk

std.jsonnet:36:8-31 function
std.jsonnet:36:8-31 function
std.jsonnet:560:9-26 function
std.jsonnet:736:15-50 thunk
std.jsonnet:741:24 thunk
std.jsonnet:475:30-33
std.jsonnet:475:19-34 thunk
std.jsonnet:471:11 thunk
std.jsonnet:467:12 function
std.jsonnet:471:7-17 function
std.jsonnet:475:7-38 function
std.jsonnet:741:15-35 thunk
std.jsonnet:742:51-59 thunk
std.jsonnet:742:11-60 function
std.jsonnet:742:11-60 function
std.jsonnet:747:7-43 function
std.jsonnet:227:7-23 function
thunk
object
std.jsonnet:729:15-21 thunk
std.jsonnet:736:27-30 thunk
std.jsonnet:560:22-25 thunk

std.jsonnet:36:17
std.jsonnet:36:8-19 thunk

std.jsonnet:36:8-31 function
std.jsonnet:36:8-31 function
std.jsonnet:560:9-26 function
std.jsonnet:736:15-50 thunk
std.jsonnet:741:24 thunk
std.jsonnet:475:30-33
std.jsonnet:475:19-34 thunk
std.jsonnet:471:11 thunk
std.jsonnet:467:12 function
std.jsonnet:471:7-17 function
std.jsonnet:475:7-38 function
std.jsonnet:741:15-35 thunk
std.jsonnet:742:51-59 thunk
std.jsonnet:742:11-60 function
std.jsonnet:742:11-60 function
std.jsonnet:747:7-43 function
std.jsonnet:227:7-23 function
object
std.jsonnet:1161:66-74 thunk

std.jsonnet:1161:66-82 function
std.jsonnet:1161:66-82 thunk
std.jsonnet:1172:43-54 thunk
std.jsonnet:1151:12 thunk
std.jsonnet:1151:5-24 function
std.jsonnet:1151:5-24 function
std.jsonnet:1172:18-55 thunk

std.jsonnet:(1164:7)-(1173:8) function
std.jsonnet:(1164:7)-(1173:8) function
std.jsonnet:1169:13-43 object

thunk

function
thunk
thunk

function
thunk
thunk
std.jsonnet:765:15-18 thunk
std.jsonnet:761:28-31
std.jsonnet:761:17-32 function
std.jsonnet:765:5-28 function
object
thunk
object
thunk

```
which makes the actual problems in user code extremely difficult to find among the noise.

(this particular case was a format string error, similar to `"%(foo)s" % {bar: ""}`)

Users are almost never interested in the details of the call path through `std.jsonnet` when debugging their code.

It would be extremely handy to have an option to `evaluate_file()` (we're using the python bindings, but I'd expect this could be applied generally) to elide all but the first and last frame in a sequence of `std.jsonnet` frames. The above stack trace would then look like:

```
std.jsonnet:731:15-42 thunk
...
std.jsonnet:227:7-23 function
thunk
object
std.jsonnet:729:15-21 thunk
...
std.jsonnet:227:7-23 function
object
std.jsonnet:1161:66-74 thunk

...
std.jsonnet:1169:13-43 object

thunk

function
thunk
thunk

function
thunk
thunk
std.jsonnet:765:15-18 thunk
...
std.jsonnet:765:5-28 function
object
thunk
object
thunk

```

We can implement this ourselves in our tooling that wraps the `evaluate_file()` call, but it would be very handy to have supported by jsonnet natively.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.