Skip to content

Fix MariaDB password mismatch between test workflow and init scripts#1799

Merged
yingbull merged 2 commits into
feature/cache-build-workflowsfrom
copilot/sub-pr-1796-again
Jan 18, 2026
Merged

Fix MariaDB password mismatch between test workflow and init scripts#1799
yingbull merged 2 commits into
feature/cache-build-workflowsfrom
copilot/sub-pr-1796-again

Conversation

Copilot AI commented Jan 18, 2026

Copy link
Copy Markdown

The workflow test sets MYSQL_ROOT_PASSWORD=testpassword but populate_db.sh hardcoded -ppassword, causing all database initialization commands to fail during container testing.

Changes

  • Modified populate_db.sh to read password from MYSQL_ROOT_PASSWORD environment variable
  • Added fallback to password for development environments where the variable matches local.env
  • Updated all mysql command invocations to use the dynamic password variable

Implementation

# Use MYSQL_ROOT_PASSWORD environment variable, fallback to 'password' for development
DB_PASSWORD="${MYSQL_ROOT_PASSWORD:-password}"

mysql -u root -p"$DB_PASSWORD" -e "CREATE DATABASE IF NOT EXISTS drugref2;"
./createdatabase_on.sh root "$DB_PASSWORD" oscar

This resolves the initialization timeout in the workflow test while maintaining compatibility with existing development environments.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.


Summary by cubic

Updates container image caching in build workflows based on feedback from #1796 to reduce unnecessary rebuilds and improve cache invalidation. Also fixes devcontainer DB initialization by using the MYSQL_ROOT_PASSWORD env var to avoid password mismatches in development and tests.

Written for commit 1a8b273. Summary will update on new commits.

@coderabbitai

coderabbitai Bot commented Jan 18, 2026

Copy link
Copy Markdown

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Comment @coderabbitai help to get the list of available commands and usage tips.

Co-authored-by: yingbull <8680161+yingbull@users.noreply.github.com>
Copilot AI changed the title [WIP] Update caching for container images based on feedback Fix MariaDB password mismatch between test workflow and init scripts Jan 18, 2026
Copilot AI requested a review from yingbull January 18, 2026 17:07
@yingbull yingbull marked this pull request as ready for review January 18, 2026 17:15
Copilot AI review requested due to automatic review settings January 18, 2026 17:15
@yingbull yingbull merged commit 5b3c15b into feature/cache-build-workflows Jan 18, 2026
6 of 7 checks passed
@yingbull yingbull deleted the copilot/sub-pr-1796-again branch January 18, 2026 17:15

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

No issues found across 1 file

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Copilot AI left a comment

Copy link
Copy Markdown

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 a critical database initialization failure in the container test workflow caused by password mismatch. The workflow sets MYSQL_ROOT_PASSWORD=testpassword for testing, but the initialization script hardcoded -ppassword, causing all database setup commands to fail.

Changes:

  • Modified populate_db.sh to dynamically read password from MYSQL_ROOT_PASSWORD environment variable
  • Added fallback to password for development environments (maintains backward compatibility)
  • Updated all 6 mysql command invocations to use the dynamic password variable

Comment on lines +13 to +18
mysql -u root -p"$DB_PASSWORD" -e "CREATE DATABASE IF NOT EXISTS drugref2;"
mysql -u root -p"$DB_PASSWORD" drugref2 < /database/mysql/development-drugref.sql
echo 'Loading demo data for development...'
mysql -u root -ppassword oscar < /scripts/development.sql
mysql -u root -p"$DB_PASSWORD" oscar < /scripts/development.sql
echo 'Preparing demographic names for development environment...'
mysql -u root -ppassword oscar < /database/mysql/updates/update-2025-11-06-demo-name-sanitization.sql
mysql -u root -p"$DB_PASSWORD" oscar < /database/mysql/updates/update-2025-11-06-demo-name-sanitization.sql

Copilot AI Jan 18, 2026

Copy link

Choose a reason for hiding this comment

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

The password variable should not be directly concatenated with the -p flag in mysql commands. When the password contains special characters or spaces, this can cause parsing issues. The current pattern -p"$DB_PASSWORD" works but is not the recommended approach for shell scripts.

Consider using one of these safer alternatives:

  1. Use MYSQL_PWD environment variable: MYSQL_PWD="$DB_PASSWORD" mysql -u root ...
  2. Use mysql config file: Create a temporary .my.cnf with credentials
  3. Separate the flag and password: mysql -u root -p"${DB_PASSWORD}" ... with braces for clarity

While the current implementation will work for the expected password values ('password' and 'testpassword'), using MYSQL_PWD would be more robust and follow MySQL best practices.

Copilot uses AI. Check for mistakes.
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.

3 participants