question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support multi-line strings in Database rules JSON

See original GitHub issue

I’m trying to do a simple database rules deploy using version 3.6.0 and I recieve the following error on the CL.

Error: There was an error loading firebase.json:

Unexpected token ' ' at 6:35
      ".write": "data.exists() &&
                                 ^
Having trouble? Try firebase deploy --help

My rules are saved in a file ‘database_rules.json’, my firebase.json file looks like this:

{
  "rules": "database_rules.json",
  "hosting": {
    "public": "./",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**",
      "functions",
      "gulpfile.js"
    ]
  }
}

My rules are the following:

{
  "rules": {
    ".validate": "auth !== null",
    "_const": {
      ".read":"true",
      ".write": "data.exists() &&
          newData.exists()"
    }
  }
}

I was under the impression multi-line strings were OK, as they publish fine in the rules editor on the console. If this is intended, what’s the work-around to get this to deploy whilst preserving the newlines so they stay readable in the console?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
mbleighcommented, Apr 11, 2017

Multi-line strings are not currently supported by the CLI when deploying rules. I’ll change the title of this to reflect that as a bug/feature request.

1reaction
danielo515commented, Apr 8, 2021

Thanks for the tip @samtstern but how that helps? Broken strings are also a syntax error on JS unless you use inverted ticks `` And if that is supported inside a JSON file, at that point the file may be better defined as a JS file insted

Read more comments on GitHub >

github_iconTop Results From Across the Web

Are multi-line strings allowed in JSON? - Stack Overflow
While not standard, I found that some of the JSON libraries have options to support multiline Strings. I am saying this with the...
Read more >
Security Rules language - Firebase - Google
Realtime Database rules use a syntax that looks like JavaScript in a JSON ... The Firebase Security Rules language also supports function declarations....
Read more >
Storing multi-line strings in JSON with JSONLint - Gun.io
This quick hack helps find a way to store multi-line strings in JSON to interact with JS and Node.
Read more >
How to Collect and Manage All of Your Multi-Line Logs
Logging to JSON. The simplest way to ensure that your multi-line logs are processed as single events is to log to JSON. For...
Read more >
An Introduction to JSON | DigitalOcean
Each of the data types that are passed in as values into JSON will maintain their own syntax, meaning strings will be in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found