Skip to content

regexp issue in get migration version #151

@morus

Description

@morus

The regexp to get the latest migration version (lib/health_check/utils.rb, line 120) is not precise enough.

We deploy our staging instances into paths named after the branch and name the branches with a ticket number prefix.

Now I had a branch 9876_forbid... and full migration names like
/var/www/rails/9876_forbid_whatever/releases/20250616051503/db/migrate/20250512111821_add_table.rb

The regexp /0*([0-9]+)_[_.a-zA-Z0-9]*.rb/ is expected to read the migration number 20250512111821 but reads 9876 as orb in forbid matches .rb (the . is not excaped, and the .rb does not have to be at the end of string).

As a result the instance is considered not healthy...

As a fix one might

  • escape the . /0*([0-9]+)_[_.a-zA-Z0-9]*\.rb/
  • add a $ for end of string after the .rb
  • change it further into /0*([0-9]+)_[^\/]\.rb$/ (anything except / allowed in migration filename)

I can provide a PR if there is a chance for a new version.

OTOH maybe this only showed up, because the fallback from rails methods was used, which is already reported and fixed in #147

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions