-
Notifications
You must be signed in to change notification settings - Fork 336
fix(cli): don't send dynamic IR bodies in registerApiDefinition request #17426
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
devin-ai-integration
wants to merge
3
commits into
main
Choose a base branch
from
devin/1786738697-fix-register-api-definition-payload
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
6 changes: 6 additions & 0 deletions
6
packages/cli/cli/changes/unreleased/fix-register-api-definition-payload-too-large.yml
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| - summary: | | ||
| Fix `PAYLOAD_TOO_LARGE` failures when publishing docs for large APIs with dynamic snippets. The | ||
| dynamic IRs were being sent inline in the `registerApiDefinition` request once per SDK language, | ||
| even though the registry only needs the language names to issue upload URLs (the IRs are uploaded | ||
| to S3 separately). | ||
| type: fix |
25 changes: 25 additions & 0 deletions
25
.../remote-generation/remote-workspace-runner/src/__test__/toRegisterDynamicIRsInput.test.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| import { describe, expect, it } from "vitest"; | ||
| import { toRegisterDynamicIRsInput } from "../toRegisterDynamicIRsInput.js"; | ||
|
|
||
| describe("toRegisterDynamicIRsInput", () => { | ||
| it("returns undefined when there are no dynamic IRs", () => { | ||
| expect(toRegisterDynamicIRsInput(undefined)).toBeUndefined(); | ||
| }); | ||
|
|
||
| it("preserves the language keys", () => { | ||
| const result = toRegisterDynamicIRsInput({ | ||
| python: { dynamicIR: { types: {} } }, | ||
| typescript: { dynamicIR: { types: {} } } | ||
| }); | ||
|
|
||
| expect(Object.keys(result ?? {}).sort()).toEqual(["python", "typescript"]); | ||
| }); | ||
|
|
||
| it("strips the IR bodies so they are not sent in the registration request", () => { | ||
| const dynamicIR = { types: { User: { name: "User" } } }; | ||
| const result = toRegisterDynamicIRsInput({ python: { dynamicIR }, go: { dynamicIR } }); | ||
|
|
||
| expect(result).toEqual({ python: {}, go: {} }); | ||
| expect(JSON.stringify(result)).not.toContain("User"); | ||
| }); | ||
| }); |
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
18 changes: 18 additions & 0 deletions
18
...cli/generation/remote-generation/remote-workspace-runner/src/toRegisterDynamicIRsInput.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| import type { APIV1Write } from "@fern-api/fdr-sdk"; | ||
|
|
||
| type DynamicIr = APIV1Write.DynamicIr; | ||
|
|
||
| /** | ||
| * FDR only reads the language keys of `dynamicIRs` when registering an API definition — it mints one | ||
| * presigned upload URL per language, and the IRs themselves are uploaded directly to S3 afterwards. | ||
| * Sending the IR bodies inline duplicates the entire IR once per language in the registration request | ||
| * body, which can exceed the server's request size limit for large APIs. | ||
| */ | ||
| export function toRegisterDynamicIRsInput( | ||
| dynamicIRsByLanguage: Record<string, DynamicIr> | undefined | ||
| ): Record<string, DynamicIr> | undefined { | ||
| if (dynamicIRsByLanguage == null) { | ||
| return undefined; | ||
| } | ||
| return Object.fromEntries(Object.keys(dynamicIRsByLanguage).map((language) => [language, {}])); | ||
| } | ||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔵 suggestion
Worth confirming that no deployed FDR version (including self-hosted registries pinned to older releases) consumes
dynamicIRs[lang].dynamicIRfrom the registration body. If any do, this silently drops their dynamic snippets rather than failing loudly. If the S3 upload path is the only consumer everywhere, ignore.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Checked this in fern-platform: no FDR version has ever read the IR body from the register request.
dynamicIRfirst appears in FDR source inchore(fdr): separate dynamic ir uploads(31cf0be, fern-platform#3378) — before that the field didn't exist in the register contract at all, so older/self-hosted registries ignore it as an unknown field.getDynamicIrsUploads→S3Service.getPresignedApiDefinitionDynamicIRsUploadUrls, which iteratesObject.entries(dynamicIRs)and discards the value (for (const [language, _dynamicIr] of ...)) to mint one presigned URL per language. Reads go throughloadDynamicIRFromS3, i.e. S3 is the only source of truth.dynamicIR: {}(servers/fdr/src/__test__/local/services/api.test.ts), and the schema isz.object({ dynamicIR: z.unknown() }), so an empty object is valid input rather than a validation failure.So dropping the bodies can't silently lose snippets — a registry that failed to receive the IR would fail at the upload/read step, not silently.