fix(cli): validate migration name and correctly report created migration files#4103
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes issues in the scripts/cli migration helper commands by adding basic argument validation and correcting the final “created” output so it reports the actual migration files created.
Changes:
- Add required-argument validation for migration name in
create_migration()andcreate_product_migration(). - Quote migration file paths in
touchcalls to handle paths safely. - Fix the final output message to reference
$UP_MIG_FILEand$DOWN_MIG_FILE(instead of undefined$MIG_FILE).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
0525e7d to
365067f
Compare
…ion files Signed-off-by: Muawiya-contact <contactmuawia@gmail.com>
365067f to
a32a0f3
Compare
|
Hi @gaspergrom, @joanagmaia, @themarolt 👋 Just a friendly ping — this PR fixes two bugs in the migration CLI helpers (undefined variable output + missing input validation). It's a low-risk, single-file shell script change. Would love to get your eyes on it when you have a moment. Happy to make any adjustments if needed! Thanks 🙏 |
|
@Muawiya-contact - the change looks ok - it would fail anyway later on with flyway but it's good that it can be prevented here as well - please merge main branch so it's ok to merge. cc @joanagmaia |
|
@themarolt thanks for your honest feedback, I have merged the main branch on it. Can you take a look at it, #4075 please? |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
scripts/cli:312
- Same issue as
create_migration():xargswill strip quotes/backslashes during parsing, so an invalid migration name may be altered into a valid one and pass validation. Prefer trimming with Bash string ops (orsed) without shell-style parsing semantics, then validate.
MIG_NAME="$(printf '%s\n' "$1" | tr -s ' ' | xargs)"
if [[ -z "$MIG_NAME" ]] || [[ ! "$MIG_NAME" =~ ^[A-Za-z0-9_-]+$ ]]; then
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Reviewed by Cursor Bugbot for commit 7fa0b52. Configure here.

Problem
Two bugs in
scripts/climigration helpers:$MIG_FILEis printed in final output but never definedsilently creates broken files like
V123456__ .sqltouchcallsFix
$UP_MIG_FILEand$DOWN_MIG_FILEintouchcallsFiles Changed
scripts/cliCloses #4102
Note
Low Risk
Low risk: small bash-script hardening for migration file creation (input validation, quoting, and log output) with no runtime impact beyond rejecting invalid names.
Overview
Tightens the
scripts/climigration helpers by trimming/normalizing the provided migration name, rejecting empty/invalid names, and exiting with a clear error.Fixes migration file creation by quoting
touchpaths and updating the output to print the actualUP_MIG_FILE/DOWN_MIG_FILEnames instead of an undefined variable.Reviewed by Cursor Bugbot for commit 7fa0b52. Bugbot is set up for automated code reviews on this repo. Configure here.