Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

YAML Config error messages are pretty bad #168

MaxGabriel opened this issue Apr 20, 2019 · 3 comments


Copy link

commented Apr 20, 2019

The error messages you get from a project using the YAML config parser, like a scaffolded yesod project, are pretty bad. There isn't much indication of what caused the problem at all. For example, today I had some config like this:

  api-token: "_env:SLACK_API_TOKEN:1234"

And I removed 1234 because I didn't want to send Slack messages from my localhost after I was done testing. But that caused this error:

mercury-web-backend: Could not convert to expected type: expected Text, encountered Null
CallStack (from HasCallStack):
  error, called at src/Data/Yaml/Config.hs:201:20 in yaml-

Which doesn't give any indication of what it was trying to parse. I actually thought it was a different field for 10 minutes or so.

Edit: sorry, posted before I was finished writing.

snoyberg added a commit that referenced this issue Apr 23, 2019

This comment has been minimized.

Copy link

commented Apr 23, 2019

I won't claim to understand how things work in aeson, but the change I introduced in 4210fa0 seems to produce better error messages. Can you give it a shot before I release?


This comment has been minimized.

Copy link

commented Apr 23, 2019

Hm, I'm still getting bad error messages. I did this:

  1. Scaffolded a yesod-postgres site

  2. Added this to extra-deps, with allow-newer: true in my global config

- git:
  commit: 4210fa09e7b043ff18f71e32e74055fcbb418be1
  - yaml
- libyaml-
  1. Set copyright in settings.yml to copyright: "_env:COPYRIGHT:"

  2. Ran stack run and got this:

/private/tmp/new-yaml5/src/Settings/StaticFiles.hs:1:1: error:
    Exception when trying to run compile-time code:
      expected Text, encountered Null
CallStack (from HasCallStack):
  error, called at src/Settings.hs:132:20 in new-yaml5-0.0.0-9rQ0xSiEFL2IyOnxx8O9Pf:Settings
    Code: staticFiles (appStaticDir compileTimeAppSettings)
1 | {-# LANGUAGE NoImplicitPrelude #-}
  | ^

Completed 5 action(s).

--  While building package new-yaml5-0.0.0 using:
      /Users/maximiliantagher/.stack/setup-exe-cache/x86_64-osx/Cabal-simple_mPHDZzAJ_2.2.0.1_ghc-8.4.4 --builddir=.stack-work/dist/x86_64-osx/Cabal- build lib:new-yaml5 exe:new-yaml5 --ghc-options " -ddump-hi -ddump-to-file -fdiagnostics-color=always"
    Process exited with code: ExitFailure 1

This comment has been minimized.

Copy link

commented Apr 28, 2019

Can you try to repro it against just the yaml library? It may be that this is something in Yesod.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
2 participants
You can’t perform that action at this time.