-
Notifications
You must be signed in to change notification settings - Fork 907
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
Display accurate message for INACCESSIBLE_SCHEMA error #7157
Changes from 6 commits
403cc7c
bbf2f0d
f0d44af
3033065
f10dcc6
ff205aa
5bf25ee
f18f94a
87943a9
932be9c
70d9d69
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,7 +61,7 @@ export async function migrateSchema(args: { | |
if (!shouldDeleteInvalidConnectors && invalidConnectors.length) { | ||
const cmd = suggestedCommand(serviceName, invalidConnectors); | ||
throw new FirebaseError( | ||
`Command aborted. Try deploying compatible connectors first with ${clc.bold(cmd)}`, | ||
`Command aborted. Try deploying those connectors first with ${clc.bold(cmd)}`, | ||
); | ||
} | ||
const migrationMode = incompatible | ||
|
@@ -315,11 +315,29 @@ async function ensureServiceIsConnectedToCloudSql( | |
} | ||
|
||
function displaySchemaChanges(error: IncompatibleSqlSchemaError) { | ||
const message = | ||
"Your new schema is incompatible with the schema of your CloudSQL database. " + | ||
"The following SQL statements will migrate your database schema to match your new Data Connect schema.\n" + | ||
error.diffs.map(toString).join("\n"); | ||
logLabeledWarning("dataconnect", message); | ||
switch (error.violationType) { | ||
case "INCOMPATIBLE_SCHEMA": | ||
{ | ||
const message = | ||
"Your new schema is incompatible with the schema of your CloudSQL database. " + | ||
"The following SQL statements will migrate your database schema to match your new Data Connect schema.\n" + | ||
error.diffs.map(toString).join("\n"); | ||
logLabeledWarning("dataconnect", message); | ||
} | ||
break; | ||
case "INACCESSIBLE_SCHEMA": | ||
{ | ||
const message = | ||
"Cannot access your CloudSQL database to validate schema. " + | ||
"The following SQL statements can setup a new database schema.\n" + | ||
error.diffs.map(toString).join("\n"); | ||
logLabeledWarning("dataconnect", message); | ||
logLabeledWarning("dataconnect", "Some SQL resources may already exist."); | ||
} | ||
break; | ||
default: | ||
throw new FirebaseError("Unknown schema violation type: " + error.violationType); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Include the error message here too - if this ever get hit, it will be very helpful to have it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unfortunately, at this point, we don't have access to the original error message. I can include the whole diff error detail here. |
||
} | ||
} | ||
|
||
function toString(diff: Diff) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems fragile to future changes - are we sure that we'll always return only one precondition error detail (maybe)? Are we sure that it will always contain exactly 1 violation (probably not)?
Would prefer something at least like like:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is true right now. If backend returns
IncompatibleSqlSchemaError
, the firstPreconditionFailure
should be that.Though you made a good point on future changes. Let me make it detect the first violation type that match.