Skip to content

fix: sync Docker runtime Python with builder and harden Renovate config - #628

Merged
sergeykad merged 6 commits into
homeassistant-ai:masterfrom
sergeykad:fix/docker-python-version-sync
Feb 17, 2026
Merged

fix: sync Docker runtime Python with builder and harden Renovate config#628
sergeykad merged 6 commits into
homeassistant-ai:masterfrom
sergeykad:fix/docker-python-version-sync

Conversation

@sergeykad

Copy link
Copy Markdown
Collaborator

What does this PR do?

Fixes broken Docker images caused by Renovate PR #598 independently bumping the runtime Python image from 3.13 to 3.14 while the builder stage remained on 3.13. This caused ModuleNotFoundError: No module named 'ha_mcp' in all three Docker images because the venv's site-packages lives under
python3.13/ but the 3.14 runtime looks under python3.14/.

Changes:

Dockerfiles (all three):

  • Revert runtime image to Python 3.13, matching the builder stage
  • Drop Debian codename from runtime tags (python:3.13-slim instead of python:3.13-slim-bookworm) so latest Debian is used automatically
  • Upgrade builder images from bookworm to trixie (current stable Debian)

Renovate config:

  • Disable dockerfile manager for python images to prevent independent runtime bumps that break builder/runtime compatibility
  • Use sed backreference \(-[a-z]\+-slim\) for builder image patterns so Debian codename upgrades don't require changing renovate.json
  • Add missing files to postUpgradeTasks: homeassistant-addon-dev/Dockerfile, _build-and-release.yml, build-binary.yml, hotfix-release.yml, performance-tests.yml
  • Add sed command for runtime image tags (python:3.X-slim pattern)
  • Add pr.yml to builder image sed (was missing, has uv container images)

Verified by simulation: Ran all Renovate sed commands against the updated files simulating a 3.13→3.14 upgrade — zero remaining 3.13 references, all Debian codenames preserved.

Type of change

  • 🐛 Bug fix
  • ✨ New feature
  • 📚 Documentation
  • 🔧 Maintenance/refactor
  • 💥 Breaking change

Testing

  • I have tested these changes with a LLM agent
  • All automated tests pass (uv run pytest)
  • Code follows style guidelines (uv run ruff check)

All 11 Docker/add-on tests pass (previously test_addon_startup_logs always failed):

tests/addon/test_addon_startup.py::TestAddonStartup::test_addon_startup_logs PASSED
tests/addon/test_addon_startup.py::TestAddonStartup::test_addon_startup_custom_secret_path PASSED
tests/addon/test_addon_startup.py::TestAddonStartup::test_addon_startup_missing_supervisor_token PASSED
tests/test_docker/test_docker_build.py::TestDockerBuild::test_dockerfile_builds_successfully PASSED
tests/test_docker/test_docker_build.py::TestDockerBuild::test_uv_not_in_runtime PASSED
tests/test_docker/test_docker_build.py::TestDockerBuild::test_ha_mcp_command_exists PASSED
tests/test_docker/test_docker_build.py::TestDockerBuild::test_runs_as_non_root_user PASSED
tests/test_docker/test_docker_build.py::TestDockerBuild::test_python_version PASSED
tests/test_docker/test_docker_compose.py (3 tests) PASSED

Checklist

  • I have updated documentation if needed

semantic-release and others added 3 commits February 10, 2026 10:52
Automatically generated by python-semantic-release
Renovate PR homeassistant-ai#598 bumped the runtime Python image from 3.13 to 3.14
independently of the builder stage, causing ModuleNotFoundError in all
three Docker images. The venv is built with Python 3.13 site-packages
but the 3.14 runtime looks under python3.14/, so nothing is found.

- Revert all three Dockerfiles to Python 3.13 runtime, matching builder
- Drop Debian codename from runtime tags (python:3.13-slim instead of
  python:3.13-slim-bookworm) so latest Debian is used automatically
- Disable Renovate dockerfile manager for python images to prevent
  independent runtime bumps that break builder/runtime compatibility
- Add missing files to Renovate postUpgradeTasks: addon-dev Dockerfile,
  _build-and-release.yml, build-binary.yml, hotfix-release.yml,
  performance-tests.yml
- Add sed command for runtime image tags (python:3.X-slim pattern)
@sergeykad
sergeykad requested a review from a team February 14, 2026 21:30
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @sergeykad, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses critical issues with Docker image builds by synchronizing Python versions between build and runtime stages, which were previously desynchronized by Renovate. It also enhances the robustness of the Renovate configuration to prevent future version mismatches and ensures consistent Python version updates across all relevant files and workflows.

Highlights

  • Docker Image Synchronization: Reverted Docker runtime Python images to 3.13 to match the builder stage, resolving ModuleNotFoundError issues caused by version mismatches.
  • Builder Image Upgrade: Upgraded builder images from Debian Bookworm to Trixie across all Dockerfiles for improved stability and up-to-date dependencies.
  • Renovate Configuration Hardening: Disabled Renovate's dockerfile manager for Python images to prevent independent runtime version bumps that could break builder/runtime compatibility.
  • Improved Renovate Patterns and File Filters: Updated Renovate's postUpgradeTasks to use more robust sed patterns with backreferences for Debian codenames and expanded file filters to cover all relevant workflow files, ensuring comprehensive Python version updates.
Changelog
  • Dockerfile
    • Updated the builder image to use trixie-slim.
    • Reverted the runtime image to python:3.13-slim.
  • homeassistant-addon-dev/Dockerfile
    • Updated the builder image to use trixie-slim.
    • Reverted the runtime image to python:3.13-slim.
  • homeassistant-addon/Dockerfile
    • Updated the builder image to use trixie-slim.
    • Reverted the runtime image to python:3.13-slim.
  • renovate.json
    • Added a rule to disable the dockerfile manager for Python images.
    • Modified a sed command to use a backreference for Debian codenames and extended its application to homeassistant-addon-dev/Dockerfile and .github/workflows/pr.yml.
    • Added a new sed command for python:3.X-slim runtime image tags.
    • Expanded the PYTHON_VERSION sed command to include hotfix-release.yml and performance-tests.yml.
    • Added a sed command for python-version in _build-and-release.yml and build-binary.yml.
    • Updated fileFilters to include homeassistant-addon-dev/Dockerfile, hotfix-release.yml, performance-tests.yml, _build-and-release.yml, and build-binary.yml.
Ignored Files
  • Ignored by pattern: .github/workflows/** (1)
    • .github/workflows/pr.yml
Activity
  • No significant human activity has been recorded on this pull request since its creation.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request effectively resolves a critical build failure by synchronizing the Python versions between the builder and runtime stages in the Dockerfiles. The accompanying changes to the Renovate configuration are excellent; they not only prevent this specific issue from recurring by disabling independent Python image updates but also make the Python version upgrade process more robust and maintainable through improved sed commands and a more comprehensive list of targeted files. The changes are well-documented and clearly address the root cause. I have one minor suggestion to further improve the future-proofing of the automation script.

Comment thread renovate.json Outdated

@kingpanther13 kingpanther13 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Review: Changes Requested

PR #626 has been merged, which reverted the runtime Python images to python:3.13-slim-bookworm in all three Dockerfiles. This PR now has merge conflicts since it modifies the same lines differently (using python:3.13-slim without the codename, plus the bookworm→trixie builder upgrade).

Action needed

Rebase on current master to resolve the three Dockerfile conflicts. After rebasing, the Dockerfile changes should reflect your intended state:

  • Builder images: trixie-slim (from this PR)
  • Runtime images: python:3.13-slim without codename (from this PR, superseding #626's python:3.13-slim-bookworm)

Renovate changes look good

The Renovate hardening is solid — I verified all five sed patterns by simulation against the new file formats, and confirmed the four newly-added workflow files (hotfix-release.yml, performance-tests.yml, _build-and-release.yml, build-binary.yml) all contain the Python version references that need updating. Disabling the dockerfile manager for Python images and coordinating through the asdf postUpgradeTasks is the right approach.

pr.yml workflow change

The bookworm-slimtrixie-slim change in pr.yml CI containers is correct and consistent with the Dockerfile builder upgrade.

Summary

The code and approach are good — just needs a rebase to resolve the conflicts from #626's merge.

Sergey added 2 commits February 17, 2026 19:40
…sion-sync

# Conflicts:
#	CHANGELOG.md
#	homeassistant-addon/CHANGELOG.md
#	homeassistant-addon/config.yaml
#	pyproject.toml
#	src/ha_mcp/__init__.py
…ersion-sync

# Conflicts:
#	CHANGELOG.md
#	Dockerfile
#	homeassistant-addon-dev/Dockerfile
#	homeassistant-addon/CHANGELOG.md
#	homeassistant-addon/Dockerfile
@sergeykad
sergeykad enabled auto-merge (squash) February 17, 2026 17:53

@kingpanther13 kingpanther13 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Review: Approve

Thoroughly reviewed the diff across all 5 files. The fix is correct and the Renovate hardening is
effective.

Dockerfile changes (all 3) - Good

  • Builder: bookworm-slim to trixie-slim with updated digest
  • Runtime: python:3.13-slim-bookworm to python:3.13-slim with updated digest
  • Python 3.13 consistent between builder and runtime - fixes the root cause
  • All three Dockerfiles are in sync

.github/workflows/pr.yml - Good

  • Container images updated to match the builder Debian change (trixie-slim)

renovate.json - Good (with one observation)

The `enabled: false` rule for `python` in `dockerfile` manager is the key fix - it directly
prevents Renovate from independently bumping the runtime Python image, which was the root cause
of the breakage. This rule is active and effective.

The postUpgradeTasks improvements (better sed patterns, coverage of
homeassistant-addon-dev/Dockerfile, additional workflow files, backreference patterns for Debian
codename flexibility) are solid improvements for future Python version bumps.

Observation (pre-existing, non-blocking): The `asdf` manager is not listed in
`enabledManagers` (which only includes `custom.regex` and `dockerfile`), so the
`postUpgradeTasks` section currently will not execute - Renovate will not scan
`.python-version` without the `asdf` manager enabled. This is a pre-existing gap, not
introduced by this PR. You may want to add `asdf` to `enabledManagers` in a follow-up to
activate the postUpgradeTasks.

Trade-off acknowledged: Disabling the `python` dockerfile manager also prevents automatic
digest-only updates (security patches) for the runtime image. This is a reasonable trade-off to
prevent version drift, but worth keeping in mind for periodic manual digest updates.

Overall: clean fix, well-structured, all CI green. Ship it.
EOF
)"

@sergeykad
sergeykad merged commit 747e297 into homeassistant-ai:master Feb 17, 2026
7 checks passed
@Patch76 Patch76 mentioned this pull request Aug 12, 2026
6 tasks
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.

2 participants