Repository navigation
fix(core): use debugLogger for skipped directory warnings #3868
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 6 commits
662f0cd
8590a44
0311a7f
411cf41
6f9c47f
d2f7caa
9aa2855
93fb58f
c7b9f38
01b8f6a
56c4b28
a6f3db8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -48,6 +48,8 @@ import { CronScheduler } from '../services/cronScheduler.js'; | |||||||||||||||||
| import type { SendSdkMcpMessage } from '../tools/mcp-client.js'; | ||||||||||||||||||
| import { setGeminiMdFilename } from '../memory/const.js'; | ||||||||||||||||||
| import { canUseRipgrep } from '../utils/ripgrepUtils.js'; | ||||||||||||||||||
| import { expandHomeDir } from '../utils/paths.js'; | ||||||||||||||||||
|
|
||||||||||||||||||
| import { ToolRegistry, type ToolFactory } from '../tools/tool-registry.js'; | ||||||||||||||||||
| import { ToolNames } from '../tools/tool-names.js'; | ||||||||||||||||||
| import type { LspClient } from '../lsp/types.js'; | ||||||||||||||||||
|
|
@@ -731,7 +733,14 @@ export class Config { | |||||||||||||||||
| this.targetDir, | ||||||||||||||||||
| this.explicitIncludeDirectories, | ||||||||||||||||||
| ); | ||||||||||||||||||
| const skippedDirs = this.workspaceContext.getSkippedDirectories(); | ||||||||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Suggestion] The new skipped-directory warning branch is user-visible but currently has no direct test coverage. Existing config tests cover valid Please add a — gpt-5.5 via Qwen Code /review
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Suggestion] 重复警告:
Suggested change
— deepseek-v4-pro via Qwen Code /review
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Suggestion] Dual warning for the same skipped directory Each skipped directory produces two debug log warnings: (1) per-directory For N skipped directories, the user sees N+1 warnings with overlapping information. Consider removing or gating the per-directory warning in — glm-5.1 via Qwen Code /review |
||||||||||||||||||
| if (skippedDirs.length > 0) { | ||||||||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Suggestion] 警告消息硬编码了
Suggested change
— deepseek-v4-pro via Qwen Code /review |
||||||||||||||||||
| this.debugLogger.warn( | ||||||||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Critical] Warning is invisible to users — goes to debug log only, not to The skipped-directory warning uses Downstream tool calls targeting those directories fail with "Path is not within workspace" with no clear root cause.
Suggested change
Note: this requires moving the block to after — glm-5.1 via Qwen Code /review |
||||||||||||||||||
| `The following --include-directories paths were skipped because they do not exist or are not readable:\n${skippedDirs.map((d) => ` - ${expandHomeDir(d)}`).join('\n')}`, | ||||||||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Critical] 被跳过目录的聚合警告仅通过 建议同时对被跳过的关键路径输出 另外,警告消息将其原因统一归为 "do not exist or are not readable",但 — deepseek-v4-pro via Qwen Code /review |
||||||||||||||||||
| ); | ||||||||||||||||||
| } | ||||||||||||||||||
| this.debugMode = params.debugMode; | ||||||||||||||||||
|
|
||||||||||||||||||
| this.inputFormat = params.inputFormat ?? InputFormat.TEXT; | ||||||||||||||||||
| const normalizedOutputFormat = normalizeConfigOutputFormat( | ||||||||||||||||||
| params.outputFormat ?? params.output?.format, | ||||||||||||||||||
|
|
||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -75,6 +75,24 @@ export function tildeifyPath(path: string): string { | |||||||||||||||||||||||||||||||||||
| return path; | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||
| * Expands tilde (~) and Windows-style %userprofile% to the full home directory path. | ||||||||||||||||||||||||||||||||||||
| * @param p - The path to expand. | ||||||||||||||||||||||||||||||||||||
| * @returns The expanded path. | ||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||
| export function expandHomeDir(p: string): string { | ||||||||||||||||||||||||||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Suggestion] Identical tilde/home-expansion logic exists in:
All three expand — glm-5.1 via Qwen Code /review |
||||||||||||||||||||||||||||||||||||
| if (!p) { | ||||||||||||||||||||||||||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Suggestion] Please add — gpt-5.5 via Qwen Code /review |
||||||||||||||||||||||||||||||||||||
| return ''; | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
| let expandedPath = p; | ||||||||||||||||||||||||||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Suggestion]
Suggested change
— deepseek-v4-pro via Qwen Code /review
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Suggestion]
Suggested change
— deepseek-v4-pro via Qwen Code /review |
||||||||||||||||||||||||||||||||||||
| if (p.toLowerCase().startsWith('%userprofile%')) { | ||||||||||||||||||||||||||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Suggestion]
Suggested change
— deepseek-v4-pro via Qwen Code /review |
||||||||||||||||||||||||||||||||||||
| expandedPath = os.homedir() + p.substring('%userprofile%'.length); | ||||||||||||||||||||||||||||||||||||
| } else if (p === '~' || p.startsWith('~/')) { | ||||||||||||||||||||||||||||||||||||
| expandedPath = os.homedir() + p.substring(1); | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
| return path.normalize(expandedPath); | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||
| * Shortens a path string if it exceeds maxLen, prioritizing the start and end segments. | ||||||||||||||||||||||||||||||||||||
| * Shows root + first segment + "..." + end segments when middle segments are omitted. | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -22,7 +22,9 @@ export type Unsubscribe = () => void; | |||||||||||||
| export class WorkspaceContext { | ||||||||||||||
| private directories = new Set<string>(); | ||||||||||||||
| private initialDirectories: Set<string>; | ||||||||||||||
| private readonly skippedDirectories = new Set<string>(); | ||||||||||||||
| private onDirectoriesChangedListeners = new Set<() => void>(); | ||||||||||||||
|
|
||||||||||||||
| /** | ||||||||||||||
| * Memoized realpath results. Every workspace-bounded tool call ultimately | ||||||||||||||
| * routes through {@link fullyResolvedPath} → `fs.realpathSync`; without | ||||||||||||||
|
|
@@ -50,8 +52,17 @@ export class WorkspaceContext { | |||||||||||||
| } | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| /** | ||||||||||||||
| * Returns directories that were skipped during construction because they | ||||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Suggestion] 新增的 — deepseek-v4-pro via Qwen Code /review |
||||||||||||||
| * did not exist or were not readable. | ||||||||||||||
| */ | ||||||||||||||
| getSkippedDirectories(): readonly string[] { | ||||||||||||||
| return Array.from(this.skippedDirectories); | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| /** | ||||||||||||||
| * Registers a listener that is called when the workspace directories change. | ||||||||||||||
|
|
||||||||||||||
| * @param listener The listener to call. | ||||||||||||||
| * @returns A function to unsubscribe the listener. | ||||||||||||||
| */ | ||||||||||||||
|
|
@@ -88,6 +99,7 @@ export class WorkspaceContext { | |||||||||||||
| this.directories.add(resolved); | ||||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Suggestion]
Suggested change
— deepseek-v4-pro via Qwen Code /review |
||||||||||||||
| this.notifyDirectoriesChanged(); | ||||||||||||||
| } catch (err) { | ||||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Suggestion]
Suggested change
— glm-5.1 via Qwen Code /review |
||||||||||||||
| this.skippedDirectories.add(directory); | ||||||||||||||
| debugLogger.warn( | ||||||||||||||
| `Skipping unreadable directory: ${directory} (${err instanceof Error ? err.message : String(err)})`, | ||||||||||||||
| ); | ||||||||||||||
|
|
||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Critical] 测试
should warn when includeDirectories paths are skipped中通过fs.mkdtempSync()创建了临时目录,但测试结束时从未调用fs.rmSync()清理。同一 diff 中前一个测试(should initialize WorkspaceContext with includeDirectories)正确执行了清理。每次运行该测试都会在/tmp泄漏一个空目录。同时,该测试通过
vi.mocked(fs.existsSync).mockImplementation(...)覆盖了existsSync,但测试结束后未恢复(vi.clearAllMocks()不清除实现)。建议测试末尾添加vi.mocked(fs.existsSync).mockReturnValue(true)防止泄漏到后续测试。— deepseek-v4-pro via Qwen Code /review