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

Validate data writes #79

Open
msiebuhr opened this issue Mar 12, 2015 · 3 comments
Open

Validate data writes #79

msiebuhr opened this issue Mar 12, 2015 · 3 comments
Labels

Comments

@msiebuhr
Copy link

If setting undefined as a value in a transaction, Firebase will throw an error transaction failed: Data returned contains undefined in property 'data'. If the same code is run through MockFirebase, no such error is thrown.

var Firebase = require('firebase');
var FirebaseTokenGenerator = require('firebase-token-generator');

var fbClient = new Firebase(process.env.FIREBASE_URL);
var fbTokenGenerator = new FirebaseTokenGenerator(process.env.FIREBASE_SECRET);

// Uncomment these and it will print 'FIREBASE NEVER GETS HERE');
//fbClient = new (require('mockfirebase').MockFirebase)();
//fbClient.autoFlush();

fbClient.child('deleteme').transaction(function (cur) {
    return {data: undefined}; // Big no-no
}, function (err, comitted, snap) {
    console.log('FIREBASE NEVER GETS HERE');
});
@bendrucker bendrucker self-assigned this Mar 12, 2015
@bendrucker
Copy link
Collaborator

Yeah, Firebase has a ton of validation logic that we're never going to fully replicate. Not that I'm not willing to try to create parity where possible. Just that you should be doing integration tests with the real SDK as well.

The logic that handles that validate is here:

https://github.com/firebase/firebase-bower/blob/6c7b6b95039622197aa52bf20959f4be87bd60f0/firebase-debug.js#L8578-L8615

@bendrucker bendrucker changed the title MockFirebase doesn't fail on .commit()'ing data with undefined values Validate data writes Mar 12, 2015
@bendrucker
Copy link
Collaborator

This isn't going to happen right away because I'm not willing to patch this for transactions and ignore every other write method that validates its inputs.

@bendrucker
Copy link
Collaborator

This will be implemented in 1.0 by running user inputs through to-firebase. If you really want this now, I'll take a PR to master that runs all write method input through to-firebase.

@bendrucker bendrucker removed their assignment Jul 24, 2015
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

2 participants