Skip to content

codegen: fail fast on empty captured setup variables #591

Description

@JoshMock

Opened from failing KB functional tests in test/functional/kb/definitions/. When a setup do step fails (404 on serverless, or empty result with no Fleet agents), set: {id} captures null/empty and the next command runs with an empty value. This surfaces as an opaque CLI input_error, or as an ES VALUE_NULL parse error when the empty value reaches a bulk kuery (parsing_exception: unknown token [VALUE_NULL] after [query]), instead of naming the real failure.

In codegen/functional/, after each set capture later used as a required path/body value, emit a guard:

[ -n "$VAR" ] || { echo "FAIL: setup produced empty $VAR"; exit 1; }

This turns silent bad input into an actionable message. It does not by itself make these tests pass (root cause is the failed setup step), but it stops masking it. Add a codegen unit test asserting the guard is emitted for captured-and-reused variables.

Failing test definitions (empty captured value → VALUE_NULL, stack + serverless):

  • elastic_agent_actions_post_fleet_agents_bulk_remove_collectors.yml
  • elastic_agent_actions_post_fleet_agents_bulk_request_diagnostics.yml
  • elastic_agent_actions_post_fleet_agents_bulk_rollback.yml
  • elastic_agent_actions_post_fleet_agents_bulk_unenroll.yml
  • elastic_agent_actions_post_fleet_agents_bulk_upgrade.yml
  • elastic_agents_post_fleet_agents_bulk_privilege_level_change.yml

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions