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

Got endOfInput even if config file is mapped and readable #937

Closed
jimexist opened this issue Aug 12, 2017 · 14 comments
Closed

Got endOfInput even if config file is mapped and readable #937

jimexist opened this issue Aug 12, 2017 · 14 comments
Labels
config related to the configuration options

Comments

@jimexist
Copy link

This is pertaining to docker v0.4.2.0

docker run --rm -v $(pwd)/postgrest.conf:/etc/postgrest/postgrest.conf -p 3000 -it begriffs/postgrest:v0.4.2.0 /bin/bash

root@11e9c4162571:/# cat /etc/postgrest/postgrest.conf
db-uri = "$(PGRST_DB_URI)"
db-schema = "$(PGRST_DB_SCHEMA)"
db-anon-role = "$(PGRST_DB_ANON_ROLE)"
db-pool = "$(PGRST_DB_POOL)"

server-host = "$(PGRST_SERVER_HOST)"
server-port = "$(PGRST_SERVER_PORT)"

server-proxy-uri = "$(PGRST_SERVER_PROXY_URI)"
jwt-secret = "$(PGRST_JWT_SECRET)"
secret-is-base64 = False

max-rows = "$(PGRST_MAX_ROWS)"
pre-request = "$(PGRST_PRE_REQUEST)"

root@11e9c4162571:/# ls -l /etc/postgrest/postgrest.conf
-rw-r--r-- 1 root root 380 Aug 12 02:40 /etc/postgrest/postgrest.conf

root@11e9c4162571:/# postgrest /etc/postgrest/postgrest.conf
postgrest: ParseError "/etc/postgrest/postgrest.conf" "endOfInput"
@jimexist
Copy link
Author

some update: i think it was due to invalid config file. After i populated all the envvars the problem goes away.

I think it'll be helpful to output more explanatory error messages in this case.

@jsplink
Copy link

jsplink commented Aug 18, 2017

I'm seeing this message despite an hour or two trying to solve it. Populating all envvars doesn't change the outcome for me. Running the released docker v0.4.2.0. @jimexist any chance you can share your configs (dockerfile+postgrest.conf)? I've checked against various issues/docs as well (hardcoding False for secret-is-base64 fixed the TypeError). I'll try out head of master now.

@jimexist
Copy link
Author

@jlsphar i'm just filling out all the envvars with values in the config then i'm all good

@begriffs
Copy link
Member

@jlsphar in the project chat @jcasto reported the same problem.

Can you try running the file command on your config file, like

file myfile.conf

I'm curious if it will report a different encoding than I see locally for my own config file that works properly.

@jcasto
Copy link

jcasto commented Oct 9, 2017

I am also fighting this problem.
$ file postgrest.conf postgrest.conf: ASCII text

@jcasto
Copy link

jcasto commented Oct 9, 2017

It would appear that my password for my user was too complex, and the special characters in the file were causing the binary to not function as expected.

@geohuz
Copy link

geohuz commented Jan 24, 2018

I have the same problem and solved by manually create a new file and typing all the lines in the file.

@rhysallister
Copy link

rhysallister commented Apr 19, 2019

Greetings, I had this issue as well, turned out that I was using single quotes (') to quote my strings. Ensure that you are using double quotes (").

@steve-chavez
Copy link
Member

@robx Have you seen a similar issue happen with configurator-pg?

@steve-chavez
Copy link
Member

This is still a problem.

I think our configuration format is pretty similar to TOML.

So we could try tomland and see how it fares. It looks more actively maintained.

@robx
Copy link
Contributor

robx commented Mar 7, 2020

@steve-chavez I haven't seen similar issues, but I'm also not really sure what the issue is here. I.e., there might well be some concrete issue where some wrongly quoted fields cause an unhelpful error message. I'd be happy to address such. As it stands, the issue is very vague to me.

@steve-chavez
Copy link
Member

steve-chavez commented Mar 7, 2020

@robx For now, I can reproduce the single quote issue:

## postgrest.conf
## ..
app.settings.external_api_secret = 'some_value'

## Will cause
postgrest postgrest.conf 
Error parsing config file:
        parsing support/configs/config: endOfInput

Though the main issue here is related to env var interpolation. In PostgREST/postgrest-heroku#25 (comment) it's mentioned that a config like:

export TEST=".\"https://somedomain.example/key\""

## postgrest.conf
app.settings.external_api_secret = "$(TEST)"

Would cause the endOfInput error reported here, however I cannot reproduce it.

@Fohlen could you provide a sample config that fails?

@robx
Copy link
Contributor

robx commented Mar 7, 2020

So it looks like due to the use of attoparsec any parse error will backtrack back to endOfInput. I'll have a look at switching it out for megaparsec.

@steve-chavez
Copy link
Member

The config error messages should be more descriptive now that #1457 got merged.

I'll close for now but will reopen if unclear errors are reported again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
config related to the configuration options
Development

No branches or pull requests

8 participants