Skip to content

fix(cli): validate migration name and correctly report created migration files#4103

Open
Muawiya-contact wants to merge 1 commit into
linuxfoundation:mainfrom
Muawiya-contact:fix/migrations-cli
Open

fix(cli): validate migration name and correctly report created migration files#4103
Muawiya-contact wants to merge 1 commit into
linuxfoundation:mainfrom
Muawiya-contact:fix/migrations-cli

Conversation

@Muawiya-contact
Copy link
Copy Markdown

@Muawiya-contact Muawiya-contact commented May 11, 2026

Problem

Two bugs in scripts/cli migration helpers:

  1. $MIG_FILE is printed in final output but never defined
  2. No validation when migration name argument is empty,
    silently creates broken files like V123456__ .sql
  3. File paths not quoted in touch calls

Fix

  • Added empty name validation with error + exit in both functions
  • Quoted $UP_MIG_FILE and $DOWN_MIG_FILE in touch calls
  • Fixed output message to show actual created filenames

Files Changed

  • scripts/cli

Closes #4102


Note

Low Risk
Low risk shell-script change limited to migration helper commands; main impact is stricter validation that may reject previously accepted (invalid) names.

Overview
Improves scripts/cli migration helpers by sanitizing and validating the migration name (trim/collapse spaces, require [A-Za-z0-9_-]+) and failing fast with a clear error message.

Fixes robustness issues by quoting generated migration paths in touch calls and correcting the final output to print the actual V... and U... files created (instead of an undefined $MIG_FILE).

Reviewed by Cursor Bugbot for commit a32a0f3. Bugbot is set up for automated code reviews on this repo. Configure here.

Copilot AI review requested due to automatic review settings May 11, 2026 19:46
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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() and create_product_migration().
  • Quote migration file paths in touch calls to handle paths safely.
  • Fix the final output message to reference $UP_MIG_FILE and $DOWN_MIG_FILE (instead of undefined $MIG_FILE).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread scripts/cli Outdated
Comment thread scripts/cli Outdated
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Reviewed by Cursor Bugbot for commit 365067f. Configure here.

Comment thread scripts/cli Outdated
…ion files

Signed-off-by: Muawiya-contact <contactmuawia@gmail.com>
Copilot AI review requested due to automatic review settings May 12, 2026 01:34
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.

Comment thread scripts/cli
Comment on lines +296 to +299
MIG_NAME="$(printf '%s\n' "$1" | tr -s ' ' | xargs)"
if [[ -z "$MIG_NAME" ]] || [[ ! "$MIG_NAME" =~ ^[A-Za-z0-9_-]+$ ]]; then
error "Migration name must be non-empty and contain only letters, numbers, underscores, or hyphens"
exit 1
Comment thread scripts/cli
Comment on lines +311 to +314
MIG_NAME="$(printf '%s\n' "$1" | tr -s ' ' | xargs)"
if [[ -z "$MIG_NAME" ]] || [[ ! "$MIG_NAME" =~ ^[A-Za-z0-9_-]+$ ]]; then
error "Migration name must be non-empty and contain only letters, numbers, underscores, or hyphens"
exit 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(cli): Migration helper prints undefined variable and missing input validation

2 participants