Skip to content

fix: declare the enum field under the name the wire uses - #1844

Merged
Tonours merged 1 commit into
mainfrom
fix/prd-993-schema-field-enums
Aug 24, 2026
Merged

fix: declare the enum field under the name the wire uses#1844
Tonours merged 1 commit into
mainfrom
fix/prd-993-schema-field-enums

Conversation

@Tonours

@Tonours Tonours commented Aug 24, 2026

Copy link
Copy Markdown
Member

fixes PRD-993

What

ForestSchemaField declared enum: string[] | null. The wire sends enums. Renamed the property to the name the payload actually carries, and updated the 38 fixture sites that wrote the old name.

Why

Nothing ever confronted the declared type with the received JSON. ForestHttpApi.getSchema ends in a bare cast (permissions/forest-http-api.ts:74), so a wrong declaration survived indefinitely.

Every producer and sibling type already said enums:

Role Location Declaration
agent emits agent/src/utils/forest-schema/generator-fields.ts:71 enums: [...(column.enumValues ?? [])].sort()
SaaS serializes private-api/src/serializers/schemas/field.js:9 enums
emit-side type forestadmin-client/src/schema/types.ts:78,318 enums: null | string[]
consumer type forestadmin-client/src/types.ts:170 enum ← the outlier

A consumer reading field.enum got undefined, always. The one real reader, agent-bff/src/openapi/collect-unfolding.ts:183, already read field.enums and was typed loosely enough not to complain — so the rename closes a latent hole rather than opening one.

This is not cosmetic. The same class of mismatch already shipped a 500: ForestSchemaAction.fields[].enums is declared string[] while the agent sends null for every dynamic-form action, so [...field.enums] threw a TypeError and every GET /agent/v1/context failed against such an agent. Guarded in #1838.

Scope and safety

Not a breaking change despite touching an exported interface. enum never existed on any payload, so no consumer can have been reading it successfully — undefined before, compile error after, which is the point. Kept as fix: rather than a major.

No runtime behaviour changes. No production src reads .enum on a schema field anywhere in the monorepo; the remaining .enum hits are z.enum (zod) and JSON-Schema keywords.

Note for the reviewer

The fixture renames in agent-bff and mcp-server are load-bearing, not tidying. Without them 11 suites in agent-bff and the mcp-server tool suites fail to compile under ts-jest with TS2561.

Worth knowing why that is easy to miss: agent-bff/tsconfig.json sets "include": ["src/**/*"], so yarn build does not typecheck tests. A root build passes clean while the test suites are red. Only yarn test catches it.

How to test

yarn workspace @forestadmin/forestadmin-client test
yarn workspace @forestadmin/agent-bff test
yarn workspace @forestadmin/mcp-server test

Green on this branch: forestadmin-client 284/284, agent-bff 1084/1084, mcp-server 892/892. Lint 0 errors.

Known limitation

The type-level fix has no test that can fail for it in isolation. forestadmin-client/test/schema/index.test.ts compares a hand-built fixture against itself, so it mirrors the type rather than exercising it. The real regression guard is the agent-bff and mcp-server suites, which do fail to compile when the names disagree.

Follow-ups, deliberately not in this PR

  • widen ForestSchemaAction.fields[].enums to string[] | null to match the wire; the Array.isArray guard from feat(agent-bff): serve the agent schema contract on GET /agent/v1/context #1838 stays either way
  • check whether openapi/unfolded-paths.ts:367 and openapi/collect-unfolding.ts:183 can drop their accommodations
  • before publishing: grep the SaaS front for .enum on a schema field. That cannot be checked from this repo and is still open.

Definition of Done

General

  • Write an explicit title for the Pull Request, following Conventional Commits specification
  • Test manually the implemented changes
  • Validate the code quality (indentation, syntax, style, simplicity, readability)

Security

  • Consider the security impact of the changes made

@linear-code

linear-code Bot commented Aug 24, 2026

Copy link
Copy Markdown

PRD-993

@qltysh

qltysh Bot commented Aug 24, 2026

Copy link
Copy Markdown

Qlty


Coverage Impact

This PR will not change total coverage.

🚦 See full report on Qlty Cloud »

🛟 Help
  • Diff Coverage: Coverage for added or modified lines of code (excludes deleted files). Learn more.

  • Total Coverage: Coverage for the whole repository, calculated as the sum of all File Coverage. Learn more.

  • File Coverage: Covered Lines divided by Covered Lines plus Missed Lines. (Excludes non-executable lines including blank lines and comments.)

    • Indirect Changes: Changes to File Coverage for files that were not modified in this PR. Learn more.

@Tonours
Tonours force-pushed the fix/prd-993-schema-field-enums branch from 8b2d369 to 476e799 Compare August 24, 2026 14:30
@Tonours Tonours changed the title fix(forestadmin-client): declare the enum field under the name the wire uses fix: declare the enum field under the name the wire uses Aug 24, 2026
@Tonours
Tonours merged commit 1fde29c into main Aug 24, 2026
32 checks passed
@Tonours
Tonours deleted the fix/prd-993-schema-field-enums branch August 24, 2026 14:54
forest-bot added a commit that referenced this pull request Aug 24, 2026
forest-bot added a commit that referenced this pull request Aug 24, 2026
## @forestadmin/mcp-server [1.23.1](https://github.com/ForestAdmin/agent-nodejs/compare/@forestadmin/mcp-server@1.23.0...@forestadmin/mcp-server@1.23.1) (2026-08-24)

### Bug Fixes

* declare the enum field under the name the wire uses ([#1844](#1844)) ([1fde29c](1fde29c))

### Dependencies

* **@forestadmin/agent-client:** upgraded to 1.14.2
* **@forestadmin/forestadmin-client:** upgraded to 1.43.1
forest-bot added a commit that referenced this pull request Aug 24, 2026
## @forestadmin/agent-bff [1.20.1](https://github.com/ForestAdmin/agent-nodejs/compare/@forestadmin/agent-bff@1.20.0...@forestadmin/agent-bff@1.20.1) (2026-08-24)

### Bug Fixes

* declare the enum field under the name the wire uses ([#1844](#1844)) ([1fde29c](1fde29c))

### Dependencies

* **@forestadmin/agent-client:** upgraded to 1.14.2
* **@forestadmin/forestadmin-client:** upgraded to 1.43.1
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