React-native-firebase: Paths must be non-empty strings and can't contain '.', '#', '$', '[', or ']'

Created on 30 Aug 2020  路  11Comments  路  Source: invertase/react-native-firebase

I had some problem in using react-native-firebase when I write any Query this error will be shown ,
So after Some looking of last commits i found out the issue is a validation in index.js

if (/[.#$\[\]'?]/g.test(path)) { throw new Error( "Paths must be non-empty strings and can't contain '.', '#', '$', '[', or ']'", ); }

Because First this Method will be Run
```
_syncServerTimeOffset() {
this.ref('.info/serverTimeOffset').on('value', snapshot => {
console.log(snapshot.val());

  this._serverTimeOffset = snapshot.val();
});

}


and it Has => . from its Path so Error will be Shown .

after removing => .  from regular expression  the error will be fixed like this 

if (/[#$[]'?]/g.test(path)) {
throw new Error(
"Paths must be non-empty strings and can't contain '.', '#', '$', '[', or ']'",
);
}
```

Needs Triage Bug Waiting for User Response

Most helpful comment

This is live now - please check!

All 11 comments

@binar1 can you link to the related commit + issue to helps us navigate to the root of the problem? I think I remember the one you are talking about but certainty is valuable

Additionally if you proposed a PR for it that would resolve it almost immediately (and if it's as easy as removing a character you can likely just do it using the GitHub web UI - makes the PR flow very easy)

Same issue while calling - database().ref("/online/123") - in react native firebase.

image

@owaisulwara you may edit directly in node_modules to fix the regex in your project https://github.com/ds300/patch-package will handle patch management / eventual upgrade with a nice warning

If you could post a quick PR we could have this sorted in just an hour or so though :pray:

I'm reproducing this bug in my app. Problem is with PR #4100

https://github.com/invertase/react-native-firebase/blob/4df5f87db51b169acbe17b4d7eb7e8fed59b8a66/packages/database/lib/index.js#L55 is run on init in constructor, and that immediately fail validation in the new regex at https://github.com/invertase/react-native-firebase/blob/4df5f87db51b169acbe17b4d7eb7e8fed59b8a66/packages/database/lib/index.js#L79, with the . in .info/serverTimeOffset

@fungilation if you propose a PR we can likely fix this today

What should be the fix as what was the validation supposed to be? Doesn't seem like "." should be included in the validation at all, but keep the rest of the characters ('#', '$', '[', or ']') as disallowed?

@fungilation that seems like the correct analysis

Okay, we have a PR (@fungilation -> :trophy: !) and it's marked pending merge, just waiting on the E2E tests in CI. if they pass I will merge and release

This is live now - please check!

Confirmed, working in my app

Was this page helpful?
0 / 5 - 0 ratings

Related issues

escobar5 picture escobar5  路  3Comments

csumrell picture csumrell  路  3Comments

ODelibalta picture ODelibalta  路  3Comments

romreed picture romreed  路  3Comments

alizahid picture alizahid  路  3Comments