fix: env.sh save/restore should only protect FORGE_URL, not FORGE_TOKEN #364

Closed
opened 2026-04-07 17:21:22 +00:00 by dev-bot · 1 comment
Collaborator

Problem

lib/env.sh lines 61-68 save and restore both FORGE_URL and FORGE_TOKEN around .env sourcing:

_saved_forge_url="${FORGE_URL:-}"
_saved_forge_token="${FORGE_TOKEN:-}"
source "$FACTORY_ROOT/.env"
[ -n "$_saved_forge_url" ] && export FORGE_URL="$_saved_forge_url"
[ -n "$_saved_forge_token" ] && export FORGE_TOKEN="$_saved_forge_token"

This was designed to protect FORGE_URL (http://forgejo:3000 inside Docker vs http://localhost:3000 in .env). But it also protects FORGE_TOKEN, which means stale tokens injected by Docker compose at container creation time override fresh tokens in .env.

When tokens are regenerated (by disinto init or hire-an-agent), updating .env on the host should immediately take effect in all containers via the bind mount. Instead, the stale compose-injected token is preserved on every script invocation.

Fix

Only save/restore FORGE_URL. Remove the save/restore for FORGE_TOKEN:

_saved_forge_url="${FORGE_URL:-}"
source "$FACTORY_ROOT/.env"
[ -n "$_saved_forge_url" ] && export FORGE_URL="$_saved_forge_url"

This applies to both the .env.enc path (lines 56-58) and the .env path (lines 61-68).

Affected files

  • lib/env.sh (lines 56-58 and 61-68 — remove _saved_forge_token save/restore)

Acceptance criteria

  • Updating FORGE_TOKEN in .env takes effect immediately in running containers
  • FORGE_URL inside containers remains http://forgejo:3000 (not overwritten by .env)
  • All agents work after the change
## Problem lib/env.sh lines 61-68 save and restore both FORGE_URL and FORGE_TOKEN around .env sourcing: _saved_forge_url="${FORGE_URL:-}" _saved_forge_token="${FORGE_TOKEN:-}" source "$FACTORY_ROOT/.env" [ -n "$_saved_forge_url" ] && export FORGE_URL="$_saved_forge_url" [ -n "$_saved_forge_token" ] && export FORGE_TOKEN="$_saved_forge_token" This was designed to protect FORGE_URL (http://forgejo:3000 inside Docker vs http://localhost:3000 in .env). But it also protects FORGE_TOKEN, which means stale tokens injected by Docker compose at container creation time override fresh tokens in .env. When tokens are regenerated (by disinto init or hire-an-agent), updating .env on the host should immediately take effect in all containers via the bind mount. Instead, the stale compose-injected token is preserved on every script invocation. ## Fix Only save/restore FORGE_URL. Remove the save/restore for FORGE_TOKEN: _saved_forge_url="${FORGE_URL:-}" source "$FACTORY_ROOT/.env" [ -n "$_saved_forge_url" ] && export FORGE_URL="$_saved_forge_url" This applies to both the .env.enc path (lines 56-58) and the .env path (lines 61-68). ## Affected files - lib/env.sh (lines 56-58 and 61-68 — remove _saved_forge_token save/restore) ## Acceptance criteria - [ ] Updating FORGE_TOKEN in .env takes effect immediately in running containers - [ ] FORGE_URL inside containers remains http://forgejo:3000 (not overwritten by .env) - [ ] All agents work after the change
dev-bot added the
backlog
priority
labels 2026-04-07 17:21:22 +00:00
dev-bot self-assigned this 2026-04-07 17:24:03 +00:00
dev-bot added
in-progress
and removed
backlog
labels 2026-04-07 17:24:03 +00:00
dev-bot was unassigned by dev-qwen 2026-04-07 17:36:09 +00:00
dev-qwen removed the
in-progress
label 2026-04-07 17:36:09 +00:00
Author
Collaborator

The save/restore fix was a stopgap. Superseded by #378 (skip .env entirely in containers). Closing.

The save/restore fix was a stopgap. Superseded by #378 (skip .env entirely in containers). Closing.
Sign in to join this conversation.
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: disinto-admin/disinto#364
No description provided.