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.

Throw better error for incorrect config

See original GitHub issue

I get this error:

TypeError: Cannot read property 'collection' of undefined
    at /srv/node_modules/integrify/lib/rules/replicateAttributes.js:61:18
    at Array.forEach (<anonymous>)
    at /srv/node_modules/integrify/lib/rules/replicateAttributes.js:47:22
    at cloudFunctionNewSignature (/srv/node_modules/firebase-functions/lib/cloud-functions.js:105:23)
    at /worker/worker.js:825:24
    at <anonymous>
    at process._tickDomainCallback (internal/process/next_tick.js:229:7)

I have the following Firebase Cloud Function running in Node 8 environment with Typescript code:


import * as functions from 'firebase-functions';
import * as admin from 'firebase-admin';
const { integrify } = require('integrify'); 

admin.initializeApp();
const firestore = admin.firestore();
integrify({ config: { functions, firestore } });

exports.inventory_item_replicate = integrify({
    rule: 'REPLICATE_ATTRIBUTES',
    source: {
      collection: 'inventory_item',
    },
    targets: [
      {
        collection: 'cart',
        foreignKey: 'id',
        attributeMapping: { 
            'barcode': 'barcode',
            'category': 'category', 
            'image': 'image', 
            'name': 'name', 
            'price': 'price',
            'stock': 'stock',
            'type': 'type',
        },
      },
    ],
  }); 

The replication function seems to fire correctly after an update on the original collection, as I can see from the logs, and the error is logged directly afterwards:

integrify: Detected update in [inventory_item], id [QmNKvERKZI3HFEyKz3Ft], 
new value: { ...
...
...
...
integrify: On collection [cart], applying update: { ....

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
anishknycommented, May 10, 2019

Hey @RamiYahyaRY thanks for trying out integrify!

Could you edit the configuration line thus:

integrify({ config: { functions, db: firestore } });

integrify expects two keys in the config object: functions and db.

LMK if it works. I can enhance it to throw better error message.

0reactions
anishknycommented, Jun 23, 2020

@devth lets continue this discussion at #56

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - What exception should I throw if a configuration value is ...
I would like to throw the error in the static methods that use these values, but ArgumentNullException doesn't seem right as they are...
Read more >
Throw warning on invalid config #250 - laravel/ideas - GitHub
So simply looking for a null config item is not the same as no config item found . What I am saying is...
Read more >
5.3. Choosing when to Throw a Particular Exception - O'Reilly
Thrown when a parameter value for a method is null and null is not allowed. Thrown when a parameter value for a method...
Read more >
Best Practices for exceptions - .NET - Microsoft Learn
Throw an ArgumentException exception or one of the predefined classes that derive from ArgumentException if invalid parameters are passed.
Read more >
How to Throw Exceptions in Java - Rollbar
Checked exceptions are generally caused by faults outside code like missing files, invalid class names, and networking errors. FileInputStream ...
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