Skip to content

Suggestion: use ConnectorResponseSizeLimitError typed error (re: elastic/kibana#268591) - #4

Draft
jcger wants to merge 2 commits into
fix/workflow-actions-response-limit-errorfrom
pr-268591-typed-response-size-error
Draft

Suggestion: use ConnectorResponseSizeLimitError typed error (re: elastic/kibana#268591)#4
jcger wants to merge 2 commits into
fix/workflow-actions-response-limit-errorfrom
pr-268591-typed-response-size-error

Conversation

@jcger

@jcger jcger commented May 14, 2026

Copy link
Copy Markdown
Owner

Context

This is a suggestion for elastic/kibana#268591 showing what the ConnectorAuthorizationError pattern would look like applied to the response size limit case.

What this adds

  • ConnectorResponseSizeLimitError in kbn-connector-specs — a typed error with explicit limitBytes, contentLengthBytes, and estimatedOutputBytes fields, following the same shape as ConnectorAuthorizationError. Also adds a WeakMap-based setConnectorActionErrorMeta/getConnectorActionErrorMeta API so connector actions can annotate errors with provider-specific size hints before the executor processes them.
  • responseSizeHeader on ActionDefinition — lets a connector declare which HTTP response header advertises the response size (defaults to content-length). The generated executor reads this header when a size-limit error occurs.
  • get_axios_instance.ts — adds an Axios response interceptor that converts ERR_BAD_RESPONSE errors into ConnectorResponseSizeLimitError at the point the HTTP client aborts the stream.
  • generate_executor_function.ts — catches ConnectorResponseSizeLimitError from the interceptor and rethrows it enriched with connector-specific metadata: the connector's declared responseSizeHeader value and any WeakMap-annotated hints from the action handler (e.g. Jina's x-decompressed-content-length).
  • action_executor.ts — handles ConnectorResponseSizeLimitError in the catch block (parallel to the existing isConnectorAuthorizationError branch), serializing it into the action result as errorName: 'ConnectorResponseSizeLimitError' and structured errorMeta.
  • ActionsResponseContentLengthLimitError in the workflow layer — a new ExecutionError subtype for when the Actions HTTP limit fires before the workflow step can enforce max-step-size. Gives actionable guidance including whether raising max-step-size would also raise the connector request limit.
  • connector_step.ts — replaces the errorMsg.includes('maxContentLength') string-match with errorName === 'ConnectorResponseSizeLimitError' as the primary detection path. Routes to ResponseSizeLimitError when the workflow transport limit applies (i.e. http type, or spec connector with max-step-size), or to ActionsResponseContentLengthLimitError when the actions HTTP limit fired before the workflow could apply its own limit.
  • ResponseSizeLimitError — extended to accept and surface contentLengthBytes and estimatedOutputBytes in the error message and details, including a suggested max-step-size value when one can be derived.

What this changes vs. the original PR

The cross-layer contract (actions plugin → workflow step) becomes explicit and typed instead of an untyped Record<string, unknown> bag detected by string-matching an internal Axios message. The old errorMsg.includes('maxContentLength') check is removed entirely; detection is now driven by errorName.

@jcger
jcger force-pushed the pr-268591-typed-response-size-error branch from 8a06ae2 to 9e95d24 Compare May 14, 2026 10:59
jcger pushed a commit that referenced this pull request Jul 30, 2026
## Summary

Fixes this test that has been failing CI on `main`:
```
Fleet Cypress Tests #4 / Assets - Real API for integration with ML and transforms should install integration with ML module & transforms
```

Example affected PR: elastic#277223

### Cause

This test failed recently when integration `lmd` 3.0.0 was published.
elastic#264584 fixed it.

`lmd` 3.3.0 was [recently
pusblished](elastic/integrations#19998) which
changed the transform source index from `logs-*` to
`logs-endpoint.events.process-*`. It seems likely that that source data
stream doesn't exist in CI, so the transform health would be non-green,
causing the test's final assertion
`expect(response.body.transforms[0].health.status).to.equal('green')` to
fail.

### Fix

Add a `before` step to create an empty
`logs-endpoint.events.process-default` index and delete it after the
test.

### Checklist

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [ ] The PR description includes the appropriate Release Notes section,
and the correct `release_note:*` label is applied per the
[guidelines](https://www.elastic.co/docs/extend/kibana/contributing/workflow/how-we-use-github#release-notes)
- [ ] Review the [backport
guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)
and apply applicable `backport:*` labels.

### Identify risks

N/A: fixes a failing Cypress test.
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