6 hours ago
Hi Railway team,
I'm storing a Google service-account JSON credential in an environment variable and the value keeps getting corrupted on save.
The JSON starts with { and ends with } and contains one long string field (private_key) with literal \n sequences. Via the Raw editor, the multi-line value splits line-by-line and the variable ends up holding only the first line ({"), with the rest becoming junk variables. I then minified it to a single line with jq -c and entered it through the single-variable form (Name/Value), and it still isn't stored/read as valid JSON — my app reads it via os.Getenv and gets "unexpected end of JSON input," which points to truncation on save.
Questions:
- Correct way to store a JSON value containing literal \n characters — any escaping/transformation Railway applies on save?
- Any length limit on a single variable value (this is ~2–3 KB) that could truncate it?
- Recommended pattern for service-account credentials (secret file, multi-line secret support)?
Project/Service: triviatide-backend, github repo (https://github.com/coderdix24/triviatide)
Environment: staging
Variables: FIREBASE_CREDENTIALS_JSON
Already deleted the corrupted/junk vars and re-added via the single-variable form; still reproduces. Can share a screen recording.
Thanks,
Richard
1 Replies
6 hours ago
This thread has been opened as a public bounty so the community can help solve it. The thread and any further activity are now visible to everyone.
Status changed to Open Railway • about 6 hours ago
5 hours ago
You can encode your JSON credential in a base64 string and store that as your variable. Then in your code, you'd decode that base64 string and parse that as JSON.