Sequelize can't be initialized by empty object

RESOLVED FIXED

Status

Webmaker
Thimble
RESOLVED FIXED
5 years ago
4 years ago

People

(Reporter: secretrobotron, Assigned: pomax)

Tracking

Details

Attachments

(1 attachment)

(Reporter)

Description

5 years ago
On this line, https://github.com/mozilla/thimble.webmaker.org/blob/master/lib/database.js#L16, an options object is specified without any entries.

If the `DB_` env variables are absent (which they may be on a prod server), the `options` argument is `undefined`, which is not a string. Thusly, the if condition on https://github.com/mozilla/thimble.webmaker.org/blob/master/lib/database.js#L6 will fail and initialize `options` as an empty object.

Sequelize doesn't like it: `Error: Cannot find module './dialects/undefined/connector-manager'`.

Sidenote: this actually looks like a bug in Sequelize, node, or underscore.js. Since the options object argument for Sequelize's constructor is specified inline, and "dialect" is explicitly a key, underscore.js's `extend` function doesn't replace it with the correct value. Maybe there's something we can do to accommodate for that.
(Assignee)

Comment 1

5 years ago
actually, if there's no DB_ nor a LEGACY_DB_ set, then it makes sense that this code breaks. I'll try to get that fixed fast.
(Reporter)

Comment 3

5 years ago
Comment on attachment 768013 [details] [review]
https://github.com/mozilla/thimble.webmaker.org/pull/163

Nice. I like that it's a bit more explicit now.
Attachment #768013 - Flags: review?(bobby) → review+

Comment 4

5 years ago
Commit pushed to master at https://github.com/mozilla/thimble.webmaker.org

https://github.com/mozilla/thimble.webmaker.org/commit/6c1de333334e76ca65d0da1b6f62744c882ef8d6
Merge pull request #163 from Pomax/bug887453

better legacy vs. active database handling
(Assignee)

Updated

5 years ago
Status: NEW → RESOLVED
Last Resolved: 5 years ago
Resolution: --- → FIXED
Attachment mime type: text/plain → text/x-github-pull-request
You need to log in before you can comment on or make changes to this bug.