Skip to content

Conversation

@ryoppippi
Copy link
Contributor

@ryoppippi ryoppippi commented Oct 22, 2025

Related to #125

I found a bug

Problem

tool_names validation had a bug: whitespace-only strings were filtered out but the resulting empty array was never validated.

Example:

tool_names: ['   ', '  ']  // Transformed to []
                          // No error thrown ❌

Why This Went Unnoticed

Old tests used spyOn(globalThis, 'fetch') which didn't show actual requests. The bug became visible when migrating to MSW in #129.

Fix

Added .refine() after .transform() to validate the filtered array:

.transform((value) => value.map((item) => item.trim()).filter((item) => item.length > 0))
.refine((value) => value.length > 0, {
  message: 'Tool names must contain at least one non-empty string',
})

Test Results

✅ All 10 feedback tests pass

Context

Discovered while working on MSW migration (#129).

Add validation to ensure tool_names array is not empty after trimming and filtering whitespace-only strings.

Previously, tool_names like ['   ', '  '] would be transformed to [] but not rejected, allowing invalid requests to be sent.

This adds a .refine() check after the .transform() to ensure at least one non-empty tool name remains after filtering.
Copilot AI review requested due to automatic review settings October 22, 2025 05:49
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a validation bug in the feedback tool where arrays containing only whitespace strings would pass validation after being transformed to empty arrays. The fix adds a .refine() check to ensure the array is not empty after filtering out whitespace.

Key Changes:

  • Added validation to reject empty arrays after whitespace filtering in tool_names

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Oct 22, 2025

Open in StackBlitz

npm i https://pkg.pr.new/StackOneHQ/stackone-ai-node/@stackone/ai@130

commit: 4674719

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

Copy link
Contributor

@glebedel glebedel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ryoppippi ryoppippi merged commit 5ea1c04 into main Oct 22, 2025
7 checks passed
@ryoppippi ryoppippi deleted the fix/feedback-tool-names-validation branch October 22, 2025 08:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants