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

Open
MaxGabriel opened this issue Apr 20, 2019 · 4 comments
Open

YAML Config error messages are pretty bad #168

MaxGabriel opened this issue Apr 20, 2019 · 4 comments

Comments

@MaxGabriel
Copy link

MaxGabriel 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:

slack:
  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-0.11.0.0-KWY10UhaZfM1oXgmBmK7aY:Data.Yaml.Config

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
Copy link
Owner

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?

@MaxGabriel
Copy link
Author

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

extra-deps:
- git: https://github.com/snoyberg/yaml
  commit: 4210fa09e7b043ff18f71e32e74055fcbb418be1
  subdirs:
  - yaml
- libyaml-0.1.1.0@sha256:b3fcd8c44622c75e054c2267f3fec39a58a311748000310cbc8257a4683d3f02
  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-2.2.0.1 build lib:new-yaml5 exe:new-yaml5 --ghc-options " -ddump-hi -ddump-to-file -fdiagnostics-color=always"
    Process exited with code: ExitFailure 1

@snoyberg
Copy link
Owner

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

@majkrzak
Copy link

Same problems occurs with non JSON-ed yaml parsing, so Data.Yaml.ParserreadYamlFile for example.

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

No branches or pull requests

3 participants