Skip to content

Stage credentials in a per-user dir and surface write failures - #10

Merged
KUCHITAKE merged 1 commit into
mainfrom
fix/per-user-credentials-dir
Jul 23, 2026
Merged

Stage credentials in a per-user dir and surface write failures#10
KUCHITAKE merged 1 commit into
mainfrom
fix/per-user-credentials-dir

Conversation

@KUCHITAKE

Copy link
Copy Markdown
Owner

概要

認証情報ステージングディレクトリが固定パス /tmp/devc-credentials だったため、別ユーザー(例: root で devc を実行した場合)が先に作成すると以後のユーザーは書き込めず、さらに ExtractCredentials が書き込みエラーを黙殺していたため、コンテナに gh 認証と git identity が入らないまま原因不明で起動する問題を修正する。

実際に palletizy_ws のワークスペースで発生した(root 所有の /tmp/devc-credentials が残存 → gh-token が書けず、コンテナ内 gh が未ログインのまま)。

変更内容

  • ホスト側ステージングを /tmp/devc-credentials-{uid} のユーザー別パスに変更(コンテナ側マウント先は /tmp/devc-credentials のまま)
  • ステージングへの書き込み失敗をエラーとして返す(従来は黙殺)。取得元が無い場合(gh 未インストール・未ログイン等)は従来通り非致命でスキップ
  • パス定義を config.CredentialsDir() / config.CredentialsTarget に集約
  • extractCredentials をソース注入可能な形に分離しユニットテストを追加
  • spec(SEC-003・パス一覧表)を更新

検証

  • make test 全パス(新規テスト4件 + 既存テスト更新)
  • 注: 書き込み不可ディレクトリの回帰テストは root 実行時 skip(make test は Docker 内 root のため CI では skip される。非 root のローカル go test で有効)

互換性

既存コンテナは旧マウント元を保持したままだが、devc up 時の Setup はホスト側の新ディレクトリを読むため git identity は更新される。コンテナ内の gh auth は旧固定ディレクトリが書き込み可能なら従来通り動作し、不可なら再作成(rebuild)で解消する。

🤖 Generated with Claude Code

The credentials staging dir was a fixed /tmp/devc-credentials. Once created
by another user (e.g. a root-run devc), writes from a normal user fail with
EACCES — and ExtractCredentials silently ignored write errors, so containers
came up with gh auth and git identity missing and no hint why.

- Host staging moves to /tmp/devc-credentials-{uid}; the container mount
  target stays /tmp/devc-credentials.
- Write failures during staging are now returned as errors instead of
  being discarded. Unavailable sources (gh not installed / not logged in)
  remain non-fatal skips.
- Stale credential files from a previous run are still cleared so revoked
  credentials never leak into new containers.

Existing containers keep their old mount source until recreated; `devc up`
re-runs setup with host-side reads from the new dir, so a rebuild is only
needed if the old fixed dir was unwritable.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@KUCHITAKE
KUCHITAKE merged commit a698e32 into main Jul 23, 2026
3 checks passed
@KUCHITAKE
KUCHITAKE deleted the fix/per-user-credentials-dir branch July 23, 2026 04:09
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.

1 participant