diff --git a/workspaces/orchestrator/.changeset/purple-eagles-share.md b/workspaces/orchestrator/.changeset/purple-eagles-share.md new file mode 100644 index 0000000000..a9bf1fcfc0 --- /dev/null +++ b/workspaces/orchestrator/.changeset/purple-eagles-share.md @@ -0,0 +1,5 @@ +--- +'@red-hat-developer-hub/backstage-plugin-orchestrator-backend': patch +--- + +fix: add configurable bodyParser limit diff --git a/workspaces/orchestrator/.changeset/strong-pillows-yawn.md b/workspaces/orchestrator/.changeset/strong-pillows-yawn.md new file mode 100644 index 0000000000..11bba090fd --- /dev/null +++ b/workspaces/orchestrator/.changeset/strong-pillows-yawn.md @@ -0,0 +1,5 @@ +--- +'@red-hat-developer-hub/backstage-plugin-orchestrator-common': patch +--- + +chore: add new config value for contentLengthLimit diff --git a/workspaces/orchestrator/app-config.yaml b/workspaces/orchestrator/app-config.yaml index f48392273b..d9ccf3f486 100644 --- a/workspaces/orchestrator/app-config.yaml +++ b/workspaces/orchestrator/app-config.yaml @@ -147,6 +147,8 @@ catalog: dynamicPlugins: frontend: {} orchestrator: + # Uncomment to set the content length limit for the requests. Defaults to 102400 bytes (100kb) + # contentLengthLimit: 10mb # Uncomment and configure to use the log viewer # workflowLogProvider: # loki: diff --git a/workspaces/orchestrator/plugins/orchestrator-backend/src/service/router.ts b/workspaces/orchestrator/plugins/orchestrator-backend/src/service/router.ts index 4cd897b922..c467d23702 100644 --- a/workspaces/orchestrator/plugins/orchestrator-backend/src/service/router.ts +++ b/workspaces/orchestrator/plugins/orchestrator-backend/src/service/router.ts @@ -201,7 +201,18 @@ export async function createBackendRouter( const permissionsIntegrationRouter = createPermissionIntegrationRouter({ permissions: orchestratorPermissions, }); - router.use(express.json()); + const contentLengthLimit = config.getOptionalString( + 'orchestrator.contentLengthLimit', + ); + /** + * Set the content length limit for the requests. + * Defaults to 102400 bytes (100kb) + * + * There is a possiblity that some workflows will have a very large payload, which could cause a 413 error. + * Increasing this value will allow larger payloads to be processed. + * + */ + router.use(express.json({ limit: contentLengthLimit })); router.use(permissionsIntegrationRouter); router.use('/workflows', express.text()); router.get('/health', (_, response) => { diff --git a/workspaces/orchestrator/plugins/orchestrator-common/config.d.ts b/workspaces/orchestrator/plugins/orchestrator-common/config.d.ts index 762d49ec03..5f2523080f 100644 --- a/workspaces/orchestrator/plugins/orchestrator-common/config.d.ts +++ b/workspaces/orchestrator/plugins/orchestrator-common/config.d.ts @@ -19,6 +19,11 @@ export interface Config { * Configuration for the Orchestrator plugin. */ orchestrator?: { + /** + * Set the content length limit for the requests. + * Defaults to 102400 bytes (100kb) + */ + contentLengthLimit?: string; sonataFlowService: { /** * Base URL of the Sonata Flow service.