glob: literal null and undefined directory names search the workspace root

Đang mở Phù hợp với người mới
#60,306 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@eoinhurrell đang làm issue này rồi.

Từ ngày 30/10/2026.

  • #60695 của @eoinhurrell — đang mở

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
75/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
bun, typescript
Lĩnh vực
cli, tooling

Hướng nghiên cứu

Bắt đầu tại packages/core/src/tool/plugin/glob.ts, nơi issue cho biết các đường dẫn nguyên văn bị chuyển thành undefined; lần theo cách đường dẫn được cung cấp đi đến tìm kiếm ripgrep. Tái hiện lỗi bằng tập lệnh Bun được cung cấp từ packages/core và so sánh null, undefined với ordinary. Hoàn thành khi mỗi thư mục được cung cấp chỉ trả về các tệp của chính nó và có kiểm thử hồi quy bao quát các tên nguyên văn.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

reproduced
Description

The glob tool interprets the literal directory names null and undefined as an omitted path. A search scoped to either directory instead runs from the workspace root and includes unrelated files, potentially hiding relevant results under the result limit. Other directory names work normally.

Reproduction

On dev commit 82666b6612cdb2ba13a7a26e150b21e897a80373, save the following as /tmp/oc-glob-repro.ts and run from packages/core:

bun -e "$(cat /tmp/oc-glob-repro.ts)"
import { Effect, Layer } from "effect"
import { AppNodeBuilder } from "@opencode/core/effect/app-node-builder"
import { makeLocationNode } from "@opencode/util/effect/app-node"
import { LayerNode } from "@opencode/util/effect/layer-node"
import { Environment } from "@opencode/core/environment/index"
import { Location } from "@opencode/core/location"
import { FileAccess } from "@opencode/core/file-access"
import { Permission } from "@opencode/core/permission"
import { Ripgrep } from "@opencode/core/ripgrep"
import { AbsolutePath } from "@opencode/core/schema"
import { Session } from "@opencode/core/session"
import { GlobTool } from "@opencode/core/tool/plugin/glob"
import { Tool } from "@opencode/core/tool"
import { location } from "./test/fixture/location"
import { permissionLayer } from "./test/lib/permission"
import { executeTool, registerToolPlugin, toolIdentity } from "./test/lib/tool"
import { mkdtemp, mkdir } from "node:fs/promises"
const dir = await mkdtemp("/tmp/oc-glob-")
await mkdir(`${dir}/null`)
await mkdir(`${dir}/undefined`)
await mkdir(`${dir}/ordinary`)
await Bun.write(`${dir}/null/inside.txt`, "x")
await Bun.write(`${dir}/undefined/inside.txt`, "x")
await Bun.write(`${dir}/ordinary/inside.txt`, "x")
await Bun.write(`${dir}/outside.txt`, "x")
const node = makeLocationNode({ name:"glob-repro", layer:Layer.effectDiscard(registerToolPlugin(GlobTool.Plugin)), deps:[Tool.node,Environment.node,Ripgrep.node,Location.node,FileAccess.node,Permission.node] })
const layer = AppNodeBuilder.build(LayerNode.group([Tool.node,node]), [Location.node.replace(Layer.succeed(Location.Service,Location.Service.of(location({directory:AbsolutePath.make(dir)})))),Permission.node.replace(permissionLayer({assert:()=>Effect.void}))])
await Effect.runPromise(Effect.gen(function*(){const registry=yield* Tool.Service; for(const path of ["null","undefined","ordinary"]) {const r=yield* executeTool(registry,{sessionID:Session.ID.make("ses_repro"),...toolIdentity,call:{type:"tool-call",id:`call-${path}`,name:"glob",input:{pattern:"*.txt",path}}}); console.log(path,JSON.stringify(r.output));}}).pipe(Effect.provide(layer)))

Actual: both null and undefined calls return all four files, including outside.txt; ordinary returns only ordinary/inside.txt. Logs show ripgrep runs at the workspace root for the first two calls and inside ordinary for the third. Expected: each supplied path scopes the search to that directory. This executes the registered GlobTool and real ripgrep, with a test permission fixture. glob.ts explicitly converts the two strings to undefined; its source blob matches upstream dev.

Ngôn ngữ chính
TypeScript
Star
224k
Fork
30k
Merge trung bình
7 giờ 30 phút
Pull request đã merge (30 ngày)
489

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của anomalyco/opencode

Tất cả issue của anomalyco/opencode

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.