mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-16 05:01:03 +03:00
fix(core): reject a zero limit on read calls (#63808)
This commit is contained in:
committed by
GitHub
Unverified
parent
f0f41c0164
commit
68fd7dd6b3
@@ -53,6 +53,8 @@ export const Plugin = {
|
||||
output: Output,
|
||||
execute: (input, context) => {
|
||||
return Effect.gen(function* () {
|
||||
if (input.limit === 0)
|
||||
return yield* new ToolFailure({ message: "Limit must be a positive integer" })
|
||||
if (Skill.isUri(input.path)) {
|
||||
const parsed = parseSkillUri(input.path)
|
||||
if (!parsed) return yield* new ToolFailure({ message: `File not found: ${input.path}` })
|
||||
|
||||
@@ -223,6 +223,23 @@ describe("ReadTool", () => {
|
||||
}),
|
||||
)
|
||||
|
||||
it.effect("rejects a zero limit before reading", () =>
|
||||
Effect.gen(function* () {
|
||||
const registry = yield* Tool.Service
|
||||
const result = yield* executeTool(registry, {
|
||||
sessionID,
|
||||
...toolIdentity,
|
||||
call: { type: "tool-call", id: "call-zero-limit", name: "read", input: { path: "README.md", limit: 0 } },
|
||||
})
|
||||
expect(result).toMatchObject({
|
||||
status: "error",
|
||||
error: { message: "Limit must be a positive integer" },
|
||||
})
|
||||
expect(assertions).toEqual([])
|
||||
expect(readCalls).toEqual([])
|
||||
}),
|
||||
)
|
||||
|
||||
it.effect("asks for external_directory approval before reading an external absolute path", () =>
|
||||
Effect.gen(function* () {
|
||||
const registry = yield* Tool.Service
|
||||
|
||||
Reference in New Issue
Block a user