Skip to content

Conversation

@MQ37
Copy link
Contributor

@MQ37 MQ37 commented May 30, 2025

  • fixes tool error and input handling
  • fixed test suite inconsistencies

@MQ37 MQ37 requested review from Copilot and jirispilka May 30, 2025 09:00
@github-actions github-actions bot added t-ai Issues owned by the AI team. tested Temporary label used only programatically for some analytics. labels May 30, 2025
Copy link
Contributor

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 improves input validation and error handling across various tools and fixes inconsistencies in the integration test suite.

  • Re-enabled and corrected an integration test, updated client usage, and refined reset logic.
  • Added guards for required inputs and API error handling in multiple tool commands.
  • Disabled default actors in test servers to align with new enableDefaultActors behavior.

Reviewed Changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tests/integration/suite.ts Re-enabled a skipped test and updated client/reset interactions
tests/integration/actor.server-streamable.test.ts Added enableDefaultActors: false for streamable server
tests/integration/actor.server-sse.test.ts Added enableDefaultActors: false for SSE server
src/tools/store_collection.ts Validated non-empty search strings
src/tools/run_collection.ts Wrapped runs list call in try/catch for API errors
src/tools/run.ts Added runId validation and API error handling
src/tools/key_value_store.ts Validated storeId and recordKey inputs
src/tools/helpers.ts Added validation and error handling in addTool/removeTool
src/tools/dataset.ts Added datasetId validation and wrapped calls in try/catch
src/tools/build.ts Added actorName validation and null checks in build tool
src/tools/actor.ts Added actorId validation and wrapped calls in try/catch
Comments suppressed due to low confidence (1)

src/tools/run_collection.ts:1

  • The Ajv import is unused in this file; it can be removed to clean up unused dependencies.
import { Ajv } from 'ajv';

@MQ37 MQ37 requested a review from Copilot May 30, 2025 09:28
Copy link
Contributor

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 addresses error and input handling issues across various tools and test files while also resolving inconsistencies in the test suite.

  • Updated tests to adjust server and client handling, including re-enabling a previously disabled test
  • Added input validations with clear error messages across run, dataset, key-value store, actor, and build tools
  • Improved error logging in the MCP server to handle Apify API errors with detailed messages

Reviewed Changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/integration/suite.ts Adjusted tests for default tools and server reset behavior
tests/integration/actor.server-streamable.test.ts Updated server instantiation to disable default actors
tests/integration/actor.server-sse.test.ts Updated server instantiation to disable default actors
src/tools/store_collection.ts Added validation to prevent empty search strings
src/tools/run.ts Introduced run ID validation and improved error responses
src/tools/key_value_store.ts Added validations for storeId and record key
src/tools/helpers.ts Enforced non-empty actorName check in add and remove tool functions
src/tools/dataset.ts Introduced datasetId validation and error handling for missing datasets
src/tools/build.ts Added validation to ensure actorName is provided and exists
src/tools/actor.ts Ensured actorId validation and proper error response when actor is not found
src/mcp/server.ts Enhanced error logging for Apify API errors with detailed messages
Comments suppressed due to low confidence (1)

tests/integration/suite.ts:106

  • The previously disabled test for listing default tools has been re-enabled. Please confirm that the underlying server reset issue (which previously loaded default Actors) has been resolved to avoid unexpected test failures.
it('should list all default tools and two loaded Actors', async () => {

@MQ37 MQ37 requested a review from Copilot May 30, 2025 09:47
Copy link
Contributor

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 input validation and error handling across tool commands and streamlines integration test behavior.

  • Strengthen argument schemas with minimum length checks and uniform not-found responses in tools.
  • Enhance MCP server to catch Apify API errors and report them gracefully.
  • Update integration tests to reflect new default-actor handling and improve server reset flow.

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/integration/suite.ts Re-enabled test, updated client naming and reset logic
tests/integration/actor.server-streamable.test.ts Added enableDefaultActors: false to server setup
tests/integration/actor.server-sse.test.ts Added enableDefaultActors: false to SSE server setup
src/tools/run.ts Added .min(1) for runId and uniform not-found check
src/tools/key_value_store.ts Added .min(1) validations for store and record IDs
src/tools/helpers.ts Enhanced add/remove tool validation and existence checks
src/tools/dataset.ts Added .min(1) validations and not-found responses
src/tools/build.ts Added .min(1) validation and not-found response for definitions
src/tools/actor.ts Updated imports, added .min(1) and not-found handler for actor
src/mcp/server.ts Caught ApifyApiError to return formatted error messages
Comments suppressed due to low confidence (5)

tests/integration/suite.ts:212

  • [nitpick] Variable names like firstClient and secondClient can be more descriptive (e.g., initialClient / resetClient) to clarify their roles in the test.
const firstClient = await createClientFn({ enableAddingActors: true });

tests/integration/suite.ts:217

  • The commented-out TODOs and dead code around server reset should be removed or refactored now that the new reset flow is implemented.
// TODO: The reset functions sets the enableAddingActors to false, which is not expected

tests/integration/actor.server-streamable.test.ts:26

  • Consider adding assertions to verify that default actors are indeed disabled when enableDefaultActors is set to false.
mcpServer = new ActorsMcpServer({ enableAddingActors: false, enableDefaultActors: false });

tests/integration/actor.server-sse.test.ts:24

  • Similarly, add tests to confirm that SSE streams do not include default actors when enableDefaultActors is disabled.
mcpServer = new ActorsMcpServer({ enableAddingActors: false, enableDefaultActors: false });

src/tools/helpers.ts:127

  • apifyMcpServer.tools may not exist or reflect the same collection as listAllToolNames(). Consider using listAllToolNames() or verifying the correct property for existence checks.
if (!apifyMcpServer.tools.has(parsed.toolName)) {

Copy link
Collaborator

@jirispilka jirispilka left a comment

Choose a reason for hiding this comment

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

Looks good, only one nit (questions)

@MQ37 MQ37 merged commit 0b0331c into master May 30, 2025
2 checks passed
@MQ37 MQ37 deleted the fix/error-input-handling branch May 30, 2025 10:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

t-ai Issues owned by the AI team. tested Temporary label used only programatically for some analytics.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants