Skip to content

fix(mcp): stop tsc class fields from wiping model instances in configure_environment - #279

Draft
vigneshrajsb wants to merge 1 commit into
mainfrom
fix-mcp-configure-environment-class-fields
Draft

vigneshrajsb wants to merge 1 commit into
mainfrom
fix-mcp-configure-environment-class-fields

Conversation

@vigneshrajsb

Copy link
Copy Markdown
Contributor

Description

  • configure_environment returned internal_error for any change to a service's active or branchOrExternalUrl.
  • The MCP tools are served from the tsc build of ws-server, where target: esnext emits declared model properties (id!: number, deployableId, ...) as class fields. Objection's instance.$query().patch() then overwrote the instance with undefined values, and the next read of the instance (d.deployable.dependsOnDeployableName) threw a TypeError. REST routes are built by Next/SWC and Jest by Babel, which don't emit those fields, so only MCP hit it.
  • Set useDefineForClassFields: false in tsconfig.server.json.
  • Log the original error with the request id in mapEnvironmentOperationError before mapping to internal_error; the client message is unchanged.

Verifying Changes

  • Reproduced against a throwaway Postgres/Redis with the real BuildService/OverrideService: active:false through the MCP handler failed before and passes with the option off.
  • New compile test fails without the config change; new mapper tests cover the logging and that expected errors aren't logged; handler test covers active and branchOrExternalUrl patches.
  • eslint, prettier and jest src/server/mcp src/server/models pass; tsc shows only pre-existing errors.

…ure_environment

The server build emits declared model properties as class fields, so an
Objection instance patched via $query().patch() was overwritten with
undefined values. Disable useDefineForClassFields for the server build and
log unexpected errors in the environment operation error mapper.
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.

1 participant