Skip to content

[One Workflow] fix: request bodies with oneof schemas (kibana.SetAlertsStatus, etc)#245344

Merged
Kiryous merged 18 commits intoelastic:mainfrom
Kiryous:fix/14949-bug-request-bodies-with-oneof-schemas
Dec 8, 2025
Merged

[One Workflow] fix: request bodies with oneof schemas (kibana.SetAlertsStatus, etc)#245344
Kiryous merged 18 commits intoelastic:mainfrom
Kiryous:fix/14949-bug-request-bodies-with-oneof-schemas

Conversation

@Kiryous
Copy link
Copy Markdown
Contributor

@Kiryous Kiryous commented Dec 5, 2025

Close https://github.com/elastic/security-team/issues/14949

Pull request overview

This PR fixes handling of OpenAPI request bodies that use composition schemas (oneOf, allOf, anyOf) in the Kibana workflows package. The primary focus is on enabling proper schema generation and validation for connectors like kibana.SetAlertsStatus which have multiple possible request body formats.

Key Changes:

  • Enhanced parameter extraction to recursively process oneOf, allOf, and anyOf schemas
  • Added connector contract override system for custom handling of specific operations
  • Improved Zod schema introspection to support intersection types

Before

image

After

Screenshot 2025-12-08 at 11 38 56

@Kiryous Kiryous self-assigned this Dec 5, 2025
@Kiryous Kiryous added the release_note:skip Skip the PR/issue when compiling release notes label Dec 5, 2025
@Kiryous Kiryous requested a review from a team as a code owner December 5, 2025 07:03
@Kiryous Kiryous added backport:skip This PR does not require backporting Team:One Workflow Team label for One Workflow (Workflow automation) labels Dec 5, 2025
@Kiryous Kiryous changed the title [One Workflow] fix: request bodies with oneof schemas (kibana.SetAlertsStatus, etc)) [One Workflow] fix: request bodies with oneof schemas (kibana.SetAlertsStatus, etc) Dec 5, 2025
@Kiryous Kiryous requested a review from Copilot December 5, 2025 07:13
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes handling of OpenAPI request bodies that use composition schemas (oneOf, allOf, anyOf) in the Kibana workflows package. The primary focus is on enabling proper schema generation and validation for connectors like kibana.SetAlertsStatus which have multiple possible request body formats.

Key Changes:

  • Enhanced parameter extraction to recursively process oneOf, allOf, and anyOf schemas
  • Added connector contract override system for custom handling of specific operations
  • Improved Zod schema introspection to support intersection types

Reviewed changes

Copilot reviewed 18 out of 57 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
spec/schema.ts Added metadata to FetcherConfigSchema for better documentation
spec/lib/samples/kibana_steps.ts Added comprehensive sample steps for alert triage and case management operations
spec/lib/samples/index.ts Moved operation category comments to their respective files
spec/lib/samples/es_steps.ts Added operation category comments from index file
spec/lib/insert_fetcher_to_schema.ts New utility to recursively insert fetcher config into Zod schemas
spec/lib/get_workflow_json_schema.kibana.test.ts Enhanced test descriptions to include step names
spec/lib/generate_yaml_schema_from_connectors.kibana.test.ts Enhanced test descriptions to include step names
spec/kibana/overrides/kibana.set_alerts_status.ts New override file for SetAlertsStatus operation with custom contract
spec/kibana/overrides/index.ts Exports override mappings for Kibana connectors
spec/kibana/index.ts Merges override contracts with generated connectors
scripts/shared/types.ts Added ParameterTypes interface definition
scripts/shared/oas_remove_discriminators_with_invalid_mapping.ts New preprocessor to remove invalid discriminator mappings
scripts/shared/generate_parameter_types.ts Enhanced to recursively extract parameters from composition schemas
scripts/shared/generate_parameter_types.test.ts Added test coverage for oneOf request bodies
scripts/generate_kibana_connectors/openapi_ts.config.ts Added preprocessing pipeline for OpenAPI spec before generation
common/utils/zod/get_shape_at.ts Updated to use getSchemaAtPath utility
common/utils/zod/get_shape_at.test.ts Added tests for union and nested union handling
common/utils/zod/get_shape.ts Added support for ZodIntersection schemas

@elasticmachine
Copy link
Copy Markdown
Contributor

💛 Build succeeded, but was flaky

Failed CI Steps

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
workflowsManagement 1969 1974 +5

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
workflowsManagement 4.1MB 4.3MB +188.4KB
Unknown metric groups

ESLint disabled line counts

id before after diff
@kbn/workflows 18 19 +1

Total ESLint disabled count

id before after diff
@kbn/workflows 24 25 +1

History

cc @Kiryous

Copy link
Copy Markdown
Contributor

@shahargl shahargl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@Kiryous Kiryous merged commit 8bb3e93 into elastic:main Dec 8, 2025
12 checks passed
mbondyra added a commit to mbondyra/kibana that referenced this pull request Dec 8, 2025
* commit '6647f813c9fa03ac0378e3d4756246e8dc4b4c76': (33 commits)
  [Detection Engine] Extracts Rules/Alerts/Exceptions permission to new Rules feature privileges (elastic#239634)
  [Agent Builder] Add Intro Tour (elastic#245551)
  Add datastream lifecycle support to indices metadata (elastic#245548)
  [Serverless] Update preconfigured connectors (elastic#245445)
  [Metrics][Discover] Discover to prefer line chars for time series data (elastic#244595)
  Update dependency @elastic/ebt to ^1.4.1 (main) (elastic#241629)
  [One Workflow] fix: request bodies with oneof schemas (`kibana.SetAlertsStatus`, etc) (elastic#245344)
  Update dependency ai to v5 (elastic#244675)
  Fix Discover trace waterfall behavior with duplicate spans (elastic#244984)
  [FSH] Migrated fs usage to kbn/fs for sample ingest (elastic#244163)
  Streamlang: Unskip type coercion test (elastic#245519)
  [Response Ops][Reporting] Fixing error in calculating delay value between retries (elastic#245431)
  Add TopNavMenuBeta to navigation plugin (elastic#243578)
  [scout] support custom servers configuration (elastic#244306)
  [Fleet] Run agentless background sync without dry run (elastic#245286)
  Fix Change Password Flaky Test (elastic#245443)
  Add new gap fill status for rules (elastic#242595)
  [Kibana Search] Move SLOs higher up in search results (elastic#245518)
  feat(slo): introduce find SLO instances internal route (elastic#245333)
  [FSH] Dropped unnecessary `fs` persistence for synthetics project code (elastic#244338)
  ...
@Kiryous Kiryous deleted the fix/14949-bug-request-bodies-with-oneof-schemas branch April 3, 2026 13:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:skip This PR does not require backporting release_note:skip Skip the PR/issue when compiling release notes Team:One Workflow Team label for One Workflow (Workflow automation) v9.3.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants