Bug description
I added a column to a table and hit "sync columns" on the dataset. I expected a message telling me I had one new column, instead I got "Added %s new columns to the virtual dataset" :
Screenshots/recordings
No response
Superset version
master / latest-dev
Python version
3.9
Node version
16
Browser
Firefox
Additional context
No response
Checklist
- [x] I have searched Superset docs and Slack and didn't find a solution to my problem.
- [x] I have searched the GitHub issue tracker and didn't find a similar bug report.
- [x] I have checked Superset's logs for errors and if I found a relevant Python stacktrace, I included it here as text in the "additional context" section.
Comment From: dosubot[bot]
This looks like a formatting bug in the toast message for syncing columns. The frontend expects to interpolate the number of new columns into the message, but if the backend doesn't return the expected value (for example, if diff.added
is missing or not an array), you'll see the raw %s
placeholder instead of a number. This can happen if there's an issue with how the backend computes or returns the column diff, or if the frontend doesn't properly handle null/undefined values when displaying the toast. Ensuring the backend always returns diff.added
as an array and the frontend checks for valid values before rendering the message should resolve this issue. The bug is in how the frontend and backend coordinate the data for this toast message, not in your environment or browser configuration. More details on the frontend logic can be found here.
To reply, just mention @dosu.
How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other
Comment From: rusackas
@dosu can you suggest a code change here?
Comment From: dosubot[bot]
You can fix the incomplete toast by making the toast message logic in updateColumns
more defensive. Even though columnChanges.added
is always initialized as an array, it's good practice to future-proof against accidental null/undefined assignments. Change the toast call from:
if (columnChanges.added.length) {
addSuccessToast(
tn(
'Added 1 new column to the virtual dataset',
'Added %s new columns to the virtual dataset',
columnChanges.added.length,
),
);
}
to:
if ((columnChanges.added || []).length) {
addSuccessToast(
tn(
'Added 1 new column to the virtual dataset',
'Added %s new columns to the virtual dataset',
(columnChanges.added || []).length,
),
);
}
This ensures the %s
placeholder always gets a valid number, even if added
is ever undefined or null due to future changes or unexpected data. You may want to apply the same pattern to the modified
and removed
arrays for consistency.
Reference
To reply, just mention @dosu.
How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other