Skip to content

fix(sdk): load v1 component I/O names that YAML 1.1 resolves as booleans. Fixes #13756 - #13990

Open
Yigtwxx wants to merge 1 commit into
kubeflow:masterfrom
Yigtwxx:fix/13756-yaml-boolean-io-names
Open

fix(sdk): load v1 component I/O names that YAML 1.1 resolves as booleans. Fixes #13756#13990
Yigtwxx wants to merge 1 commit into
kubeflow:masterfrom
Yigtwxx:fix/13756-yaml-boolean-io-names

Conversation

@Yigtwxx

@Yigtwxx Yigtwxx commented Aug 7, 2026

Copy link
Copy Markdown

Description of your changes:

load_component_from_text and load_component_from_file failed on v1 component YAML whose input or output name is one of the YAML 1.1 boolean words on, off, yes or no, in both flow style and block style:

name: test
inputs:
- {name: off, type: String}
implementation:
  container:
    image: alpine
    command: [echo]

PyYAML implements YAML 1.1, so yaml.safe_load resolved those unquoted scalars to Python booleans before v1_structures.ComponentSpec.from_dict ran, producing a nested TypeError:

TypeError: Error: InputSpec.from_dict(struct={'name': False, 'type': 'String'}) failed with exception:
Error: Structure "False" is incompatible with type "<class 'str'>". ...

The same coercion also affects placeholders: {inputValue: off} became {'inputValue': False}, which then fails in utils.sanitize_input_name with AttributeError: 'bool' object has no attribute 'lower'. Repairing only the name fields would therefore not be enough, and bool -> str cannot recover the original spelling (on, On, ON, ...).

Changes, all scoped to _load_component_spec_from_component_text, the single entry point for v1 component text:

  • _V1ComponentYamlLoader is a yaml.SafeLoader subclass whose implicit resolvers keep the boolean tag only for scalars starting with t/T/f/F. This matches the YAML 1.2 core schema: true/false still resolve to booleans, null/~ still resolve to null, and on/off/yes/no stay strings.
  • _normalize_v1_io_specs restores the boolean meaning of the optional field when it is written as yes/no/on/off, so component YAML that loads today keeps loading. optional is the only strictly boolean-typed field in v1_structures.
  • The same pass raises a ValueError naming the offending input or output when a name is not a string, replacing the nested TypeError from InputSpec.from_dict.

Boolean-typed defaults are unaffected: default: yes now reaches type_utils.deserialize_v1_component_yaml_default as the string 'yes', and bool_cast_fn/strtobool already map yes/no/on/off to booleans, so the resulting default is still True. A String-typed input with default: yes changes from 'True' to 'yes', which is the value the YAML actually spells.

load_documents_from_yaml and the v2 IR path are deliberately unchanged. Compiled IR YAML is emitted by PyYAML, whose emitter quotes scalars that would otherwise resolve to a non-string type, so IR round-trips correctly today.

Fixes #13756

Checklist:

Signed-off-by: Yigtwxx <yigiterdogan023@gmail.com>
@google-oss-prow
google-oss-prow Bot requested a review from droctothorpe August 7, 2026 18:46
@google-oss-prow

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign chensun for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@google-oss-prow

Copy link
Copy Markdown

Hi @Yigtwxx. Thanks for your PR.

I'm waiting for a kubeflow member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[sdk] load_component_from_text fails for v1 components with YAML-boolean input names (on, off, yes, no)

1 participant