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

Heroku environmental variables require extra quotes around values #19

Open
zacwest opened this issue Jul 4, 2017 · 5 comments
Open
Labels

Comments

@zacwest
Copy link

zacwest commented Jul 4, 2017

The environmental variables MICROPUB_PERMALINK_STYLE, MICROPUB_MEDIA_FILES_STYLE, MICROPUB_FILENAME_STYLE require quotes around the values in the Heroku configuration, though the rest don't. This manifests as "app crashed" in the Heroku logs if you do not include them.

I'm guessing it's because the values are parsed as JSON as their first step. It may be worth documenting these keys as requiring the extra quotes because it took me a little while to figure it out. At the very least, hopefully this issue is discoverable.

@voxpelli
Copy link
Owner

voxpelli commented Jul 5, 2017

Thanks for reporting @zacwest!

If we can clarify this in the README so that others can have an easier time setting it up, then that would be great. It was a while since I added it myself, so I can't remember if I had any issue with it, but looking at the Heroku web interface for setting config variables it seems to enough to just paste the JSON in there. This is a screenshot from there of the setup I've been running:

2017-07-05 at 16 18

Were you using the CLI-tool for setting these env variables? Any suggestion on a README addition that would help in the setting of those values?

Also – since you're here anyway – any feedback on how easy those JSON settings were to use otherwise? Applying JSON through env-variables is a bit weird and using the rule based fulfills expressions is even weirder, but the fact that one can customize ones setup a lot without having to modify the code one pushes to Heroku is pretty neat. I haven't gotten a lot of feedback from others though about whether it's more neat than weird or whether the weirdness is bigger than the neatness.

@zacwest
Copy link
Author

zacwest commented Jul 5, 2017

I'm using the website to edit the environmental variables. I believe this is only required for values that are strings. If they are valid JSON, like that object in the screenshot, it's able to parse it. Here's an example of what I'm using that parses without issue:

screen shot 2017-07-05 at 10 33 28 am

If I take out the wrapping " around the value, it blows up at b trying to turn that into JSON (since literals aren't supported in JSON like that).


I haven't tried using the more advanced JSON (like the dictionary matching) yet. From my perspective you've got a few options for configuration:

  • Use the environmental variables to examine the JSON.
  • Require users to fork the repository to configure the values in a file.
  • Run the service yourself and store people's deploy keys (rather than access tokens) with some kind of admin interface. This option would probably allow a lot more people to use it, but also adds a lot more burden to you.
  • Read a configuration file from the destination site's .well-known each time a micropub comes in.
  • Allow the service to have an admin interface to configure the rules and store them somewhere.

I think the last two, with some kind of dry-run-able transaction support, would be an easier way to get the configuration working.

I ended up reverting a few commits to my repo while getting things set up. Now that I think about it, allowing me to specify which branch to commit to would also help.

@pmarsceill
Copy link

Trying to deploy this to Zeit, and am hitting a similar issue when trying to deploy with the environment vars as they are documented:

> Using Node.js 9.8.0 (requested: `>=6.0.0`)
> Ready! https://micropub-to-github-sqgwdbdtwj.now.sh (copied to clipboard) [2s]
> Initializing…
> Building
> ▲ npm install
> ✓ Using "yarn.lock"
> ⧗ Installing 25 main dependencies…
> ✓ Installed 416 modules [5s]
> ▲ npm start
> [email protected] start /home/nowuser/src
> node .
> undefined:1
> src/_posts/microblog/:year-:month-:day-:slug
> ^
> SyntaxError: Unexpected token s in JSON at position 0
>     at JSON.parse (<anonymous>)
>     at parseJSON (/home/nowuser/src/lib/config.js:22:59)
>     at Object.<anonymous> (/home/nowuser/src/lib/config.js:53:20)
>     at Module._compile (module.js:649:30)
>     at Object.Module._extensions..js (module.js:660:10)
>     at Module.load (module.js:561:32)
>     at tryModuleLoad (module.js:501:12)
>     at Function.Module._load (module.js:493:3)
>     at Module.require (module.js:593:17)
>     at require (internal/module.js:11:18)
> npm ERR! code ELIFECYCLE
> npm ERR! errno 1
> npm ERR! [email protected] start: `node .`
> npm ERR! Exit status 1
> npm ERR!
> npm ERR! Failed at the [email protected] start script.
> npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
> npm ERR! A complete log of this run can be found in:
> npm ERR!     /home/nowuser/.npm/_logs/2018-03-13T22_34_02_333Z-debug.log
> No open port found. Make sure 'npm start' creates an HTTP server on a port (any).
> More details: https://err.sh/now-cli/no-open-port-found
> > Error! The build step of your project failed. To retry, run `now --force`.

Removing these specific environment vars allows me to deploy successfully, but it isn't usable because i can't customize the filename path.

@pmarsceill
Copy link

FWIW, escaping these strings with \"_posts/microblog/:year-:month-:day-:slug\" when defining the environment vars for these fixes my issue with Zeit.

@voxpelli
Copy link
Owner

voxpelli commented Nov 9, 2018

Sorry for not being responsive here – life kind of got in the way.

Are you @zacwest and @pmarsceill saying that even non-JSON configurations needs quotes and escaping? Plain strings should work with no extra effort at all – else it's a bug

@voxpelli voxpelli added the bug label Nov 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants