Fix env injection crashing on variables the compose file also sets #3

Open
agent wants to merge 1 commit from fix/env-override-merge into main
Member

Fixes deploys failing when an app's compose file sets a variable that is also in the panel's Environment tab while Pass to every container is on (the default).

The bug

prepare_env_override wrote bare keys:

services:
  "app":
    environment:
      - MAX_PHOTO_BYTES

podman-compose 1.5 normalises a bare key to None and refuses to merge it with the compose file's own value:

ValueError: can't merge value of [MAX_PHOTO_BYTES] of type <class 'str'> and <class 'NoneType'>

So any app that documents its settings as FOO: ${FOO:-default} (the pattern the Environment tab's "uses variables that aren't set" hint encourages) couldn't be deployed with injection on.

The fix

Write KEY: ${KEY} instead. Compose still fills the value in from its own environment (where panelctl already puts it), so values are still never quoted into YAML, and the panel's value still takes precedence.

Verified with podman-compose 1.5.0

compose file's environment: before after
list form (- FOO=x) crash panel value wins, other vars kept
map form (FOO: x) crash panel value wins
none ok ok
  • A value with $ and quotes (p$1 "x") passes through unchanged, with no re-interpolation.
  • I ran the patched generator lines from panelctl.sh against reudy-net/oweme's compose.yaml; the values reach the service.
  • bash -n panelctl.sh passes.
  • Not run: nix flake check and a full deploy on the VPS. This box has no Nix and no panel install.

The README's Environment variables section is updated to match.

🤖 Generated with Claude Code

https://claude.ai/code/session_013FYo6JSV1fDU1fm3LU77iF

Fixes deploys failing when an app's compose file sets a variable that is also in the panel's Environment tab while **Pass to every container** is on (the default). ## The bug `prepare_env_override` wrote bare keys: ```yaml services: "app": environment: - MAX_PHOTO_BYTES ``` podman-compose 1.5 normalises a bare key to `None` and refuses to merge it with the compose file's own value: ``` ValueError: can't merge value of [MAX_PHOTO_BYTES] of type <class 'str'> and <class 'NoneType'> ``` So any app that documents its settings as `FOO: ${FOO:-default}` (the pattern the Environment tab's "uses variables that aren't set" hint encourages) couldn't be deployed with injection on. ## The fix Write `KEY: ${KEY}` instead. Compose still fills the value in from its own environment (where panelctl already puts it), so values are still never quoted into YAML, and the panel's value still takes precedence. ## Verified with podman-compose 1.5.0 | compose file's `environment:` | before | after | |---|---|---| | list form (`- FOO=x`) | crash | panel value wins, other vars kept | | map form (`FOO: x`) | crash | panel value wins | | none | ok | ok | - A value with `$` and quotes (`p$1 "x"`) passes through unchanged, with no re-interpolation. - I ran the patched generator lines from `panelctl.sh` against reudy-net/oweme's `compose.yaml`; the values reach the service. - `bash -n panelctl.sh` passes. - Not run: `nix flake check` and a full deploy on the VPS. This box has no Nix and no panel install. The README's Environment variables section is updated to match. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_013FYo6JSV1fDU1fm3LU77iF
agent added 1 commit 2026-10-10 00:25:33 +02:00
The env override listed bare keys (- KEY). podman-compose can't merge a
bare key with a value the compose file sets for the same variable and
fails the deploy: "can't merge value of [KEY] of type str and NoneType".
Writing KEY: ${KEY} keeps values out of the YAML (compose interpolates
them from its environment) and merges with list- or map-form environment.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013FYo6JSV1fDU1fm3LU77iF
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin fix/env-override-merge:fix/env-override-merge
git checkout fix/env-override-merge

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git checkout main
git merge --no-ff fix/env-override-merge
git checkout fix/env-override-merge
git rebase main
git checkout main
git merge --ff-only fix/env-override-merge
git checkout fix/env-override-merge
git rebase main
git checkout main
git merge --no-ff fix/env-override-merge
git checkout main
git merge --squash fix/env-override-merge
git checkout main
git merge --ff-only fix/env-override-merge
git checkout main
git merge fix/env-override-merge
git push origin main
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: reudy-net/panel#3
No description provided.