Nested import resolution with header via DHALL_HEADERS


we need to add authentication to our import resolution. First we tried the approach where we define the
header directly into the dhall and refer to the credentials via environment variables. But that does not work for nested import.

So we planned to use the DHALL_HEADERS feature as described here

Using dhall 1.41.2 on windows:

set DHALL_HEADERS=[ { mapKey = "Authorization" , mapValue = "Bearer somemagictoken" } ]

then the dhall itself

let d = using headers
in  d

and calling dhall --file on it results in the following error msg:

Unbound variable: headers

What are we missing here?

Thanks in advance Christian

Hi, after some more tries I found that

  • the dhall_headers definition was wrong
  • despite the documentation the import must not include using headers

So I tried

set DHALL_HEADERS=toMap { "" = toMap { "Authorization" = "Bearer somemagictoken" } }

and the dhall

let d =
in  d

and it worked (at least on win, will try on linux later that day but I believe the result should be the same)

Can we add this as an example to the official dhall docs in some way? (In case it is correct now)

Yeah, I’d accept a pull request to fix the documentation

Here you go added docs for external header definition for url imports by christianknoepfle · Pull Request #1317 · dhall-lang/dhall-lang · GitHub
I am not a native speaker, so edits welcome :slight_smile: