Bulk command update API design can be improved to avoid footguns #7212
Unanswered
MinnDevelopment
asked this question in
API Feature Requests & Ideas
Replies: 1 comment 2 replies
-
I'd be inclined to say this should be an array of for (const commandSet of commandSets) {
sql(`DELETE FROM Commands WHERE Type = ${commandSet.type};`);
const commandsAsValues = commandSet.commands.map(command => `(${command.type}, ${command.name})`).join(',');
sql(`INSERT INTO Commands (Type, Name /* etc... */) VALUES ${commandsAsValues};`);
} Obviouslly missing assertion checks and there's a better way to map the commands internals to the database, but this shows it somewhat simply. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Right now, all commands of all types are sent as one big list to the bulk update endpoint. This becomes problematic when new types are added that a library doesn't support. In that case, the library will simply delete all of these commands unknowingly, resulting in unexpected footguns.
This has re-appeared recently with the new entry point command types
4
, resulting in this band-aid error:The only reason why this error seems to exist, is because API users are unaware about the connection between activities and other command types. Libraries, naturally, haven't implemented these types yet and thus also are entirely unaware.
Instead of implementing new types by just adding them to the same list, they should be managed as separate lists.
An example:
This can be made forward-compatible, by allowing each list to be omittable, in which case commands of those types are not changed. If a library doesn't support a specific new type of command, it will simply not send the list for that type. This allows a library to continue to function in parallel to new command types being added for various features, and removes the need for errors like shown above entirely.
Beta Was this translation helpful? Give feedback.
All reactions