test(tools): type the path-safety harnesses instead of erasing with any - #7270
Merged
Conversation
These two harnesses are the template every service copied when the path hardening sweep began, and both open with `type AnyTool = ToolConfig<any, any>` plus an `as any` at the `url(...)` call. CLAUDE.md forbids `any` outright, and because they are the template the violation propagated into ten in-flight PRs before review flagged it. Fixing the source stops the next copy inheriting it. The obvious repair does not compile. `ToolConfig` takes its param type in the contravariant position of `request.url`, so no concrete member of the barrel's union is assignable to a widened `ToolConfig<Record<string, unknown>, ...>`, and `filter`'s type-predicate overload intersects rather than replaces -- filtering the union directly leaves the mismatch standing. Seeding the enumeration as `Object.values<unknown>(...)` makes the existing `isVercelTool` / `isDaytonaTool` predicate the single narrowing point, which is the `unknown`-plus-type-guard form the guidelines actually ask for, and removes the need for a cast at the call site. Note these files have no type coverage in CI from either direction: `apps/sim/tsconfig.json` excludes `**/*.test.ts`, and vitest does not typecheck. Verified with a temporary tsconfig lifting the exclusion, confirming via `--listFiles` that both files were genuinely in the program -- an empty program also reports zero errors. That config was not committed. Behaviour is unchanged: 1129 tests pass, identical to before.
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
Greptile SummaryThis PR removes explicit
Confidence Score: 5/5The PR appears safe to merge because it changes only erased TypeScript annotations in test harnesses and introduces no observable behavior change. The barrel enumeration, filtering, parameter construction, URL invocation, and assertions emit the same runtime behavior as before, and no concrete build or test failure was established.
|
| Filename | Overview |
|---|---|
| apps/sim/tools/daytona/sandbox_path_safety.test.ts | Replaces explicit any types and casts with an unknown-first narrowing pattern; no actionable regression was identified. |
| apps/sim/tools/vercel/edge_config_path_safety.test.ts | Applies the same type-only cleanup to the Vercel path-safety harness without changing test execution behavior. |
Reviews (1): Last reviewed commit: "test(tools): type the path-safety harnes..." | Re-trigger Greptile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
These two files are the template every service copied during the path-hardening sweep, and both open with:
CLAUDE.md forbids
anyoutright ("Noany— use proper types orunknownwith type guards"). Because these are the template, the violation propagated into ten in-flight PRs before review caught it there. Fixing the source stops the next copy inheriting it.Why the obvious repair doesn't compile
Swapping in
ToolConfig<Record<string, unknown>, ToolResponse>on its own fails across the whole barrel union:ToolConfigtakes its param type in the contravariant position ofrequest.url, so no concrete member is assignable to the widened alias. Andfilter's type-predicate overload intersects rather than replaces, so filtering the union directly leaves the mismatch standing.Seeding the enumeration as
Object.values<unknown>(...)makes the existingisVercelTool/isDaytonaToolpredicate the single narrowing point — theunknown-plus-type-guard form the guidelines actually prescribe — and removes the need for a cast at the call site entirely.These files have no type coverage in CI
Worth recording, because it is why the pattern survived:
apps/sim/tsconfig.jsonexcludes**/*.test.ts, and vitest does not typecheck. So neither direction would have flagged this.I verified with a temporary tsconfig lifting the exclusion, and confirmed via
--listFilesthat both files were genuinely in the program — an empty program also reports zero errors, which is an easy way to fool yourself here. Zero errors in both. That config was not committed.Checks
vitest run tools/vercel tools/daytona— 1129 pass, identical to before (pure typing change, no behavioural effect)bun run lint— cleanbun run check:audits— 39/39check-block-registry.ts origin/staging— pass