Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

agent: log when a configured working directory is rejected and falls back to home

未关闭
#1,573 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
68/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
冷清
技术栈
go

调研方向

阅读 usershell.ResolveWorkingDir 以及两个调用点 agentssh.Server.resolveWorkingDir 和 agentproc.manager.resolveWorkingDir。首先跟踪 stat/IsDir 的拒绝逻辑和 SSH EnvInfoer 的解析过程。当非空配置回退到 home 时,调用点的 warn 级诊断包含配置的路径和实际解析出的路径,同时共享 resolver 仍不包含 logger,即视为完成。

由索引模型根据 Issue 内容生成。

描述

tech-debt

Problem

usershell.ResolveWorkingDir (introduced in coder/coder#26102) uses a configured working directory when it exists as a directory, and otherwise silently falls back to the user's home directory. The callers (the agentssh SSH command and SFTP paths, and agentproc) do not distinguish "used the configured directory" from "fell back to home," so a rejected configured directory produces no log or metric.

Scenario: an admin sets the agent directory to a path that does not exist or is not accessible (bad mount, wrong permissions). SSH and SFTP sessions silently land in $HOME. Nothing correlates the rejected directory with the session, so support cannot explain why sessions start in the wrong place.

This is pre-existing behavior. All three resolvers fell back silently before the unification, which preserved the contract rather than introducing it.

How to verify

Read usershell.ResolveWorkingDir and the two call sites (agentssh.Server.resolveWorkingDir and agentproc.manager.resolveWorkingDir). When the configured directory is non-empty but fails the stat/IsDir check, the function returns the home directory with a nil error and nothing is logged.

Desired outcome

When a non-empty configured working directory is rejected and resolution falls back to home, the agent emits a diagnostic (a warn-level log with the configured and resolved paths) at the call sites that have a logger. The shared resolver stays logger-free.

Constraints

  • Keep the shared usershell.ResolveWorkingDir free of a logger dependency. The diagnostic belongs at the call sites.
  • The SSH command path resolves against a per-session EnvInfoer (container override), so the log there should reflect the actual resolved directory rather than assume the host.

Follow-up to coder/coder#26102 (deep-review CRF-1).

🤖 Filed by Coder Agents on behalf of @mafredri.

主要语言
没有语言数据
星标
3
派生
0
PR 合并指标
30 天内没有已合并 PR

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

coder/internal 的其他 Issue

查看 coder/internal 的全部 Issue

相似的 Issue

更多 Backend & API Design Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。