Skip to content

Fix several issues with oneof responses - #924

Merged
ezilber-akamai merged 7 commits into
linode:devfrom
ezilber-akamai:fix/cli-oneof-response-property-overwriting
Sep 16, 2026
Merged

ezilber-akamai merged 7 commits into
linode:devfrom
ezilber-akamai:fix/cli-oneof-response-property-overwriting

Conversation

@ezilber-akamai

@ezilber-akamai ezilber-akamai commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

📝 Description

Fixed oneOf response properties being overwritten during schema aggregation. When a oneOf defines the same property across multiple branches, keep the most complete definition instead of letting a later, emptier branch overwrite it. This fixes fields like public.ipv6.ranges being dropped from output.

Also fixed an issue with oneOf schemas in _parse_response_model that was causing nested response data to be displayed incorrectly.

✔️ How to Test

make test-unit
make test-int TEST_CASE=test_interface_update (was previously failing)
make test-int TEST_SUITE=firewalls (was previously failing)

@ezilber-akamai
ezilber-akamai requested a review from a team as a code owner September 9, 2026 15:16
@ezilber-akamai ezilber-akamai added the bugfix for any bug fixes in the changelog. label Sep 9, 2026
@ezilber-akamai
ezilber-akamai requested a review from a team as a code owner September 9, 2026 15:16
@ezilber-akamai ezilber-akamai added the hotfix urgent fixes for production issues. label Sep 9, 2026
@ezilber-akamai
ezilber-akamai requested review from jriddle-linode and mawilk90 and removed request for a team September 9, 2026 15:16
@ezilber-akamai ezilber-akamai changed the title Fixed issue with oneof responses getting overwritten during schema aggregation Fix several issues with oneof responses Sep 9, 2026
@mawilk90

Copy link
Copy Markdown
Contributor

The tests passed locally. Thanks for addressing it!

@yec-akamai
yec-akamai requested a lite review from Copilot September 15, 2026 16:10

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Richness ties remain order-dependent, and scalar oneOf arrays can disappear from generated output.

Get a fresh assessment by requesting another Copilot review.

Review details
  • Files reviewed: 5/5 changed files
  • Comments generated: 2
  • Review effort level: Balanced

Comment thread linodecli/baked/response.py Outdated
Comment thread linodecli/baked/util.py Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Unresolved moderate schema-aggregation issues and missing coverage block approval.

Get a fresh assessment by requesting another Copilot review.

Review details

Suppressed comments (3)

linodecli/baked/util.py:121

  • The <= comparison also discards equal-richness definitions. Two branches can define the same object property with disjoint nested fields but the same score, and allOf branches are conjunctive, so keeping only the first loses fields that must be exposed. Use a composition-aware merge for ties/allOf rather than a winner-takes-all selection.
            if key in properties and _schema_richness(
                value
            ) <= _schema_richness(properties[key]):
                continue

            properties[key] = value

linodecli/baked/util.py:52

  • Each duplicate-property comparison recursively walks properties, compositions, and items. The depth cap prevents unbounded recursion but not exponential work for a cyclic schema with multiple recursive children; a branching cycle can expand to roughly 2^32 visits during one comparison and make baking unresponsive. Memoize scores by schema identity or track active nodes in addition to the depth limit.
    properties = get(schema, "properties")
    if properties:
        for _, prop in properties.items():
            score += 1 + _schema_richness(prop, _depth + 1)

linodecli/baked/util.py:58

  • _schema_richness adds 1 for every composition branch even when that branch contributes no object properties. A property defined as oneOf: [{type: string}, {type: integer}] therefore scores 2 and can beat a competing object definition with one nested field (score 1); the aggregator keeps the scalar oneOf schema, and _parse_response_model then emits only the parent value instead of the nested field. Score renderable structure rather than counting scalar alternatives, or merge the alternatives before choosing a definition.
    # Account for composite (oneOf/allOf/anyOf) definitions by summing the
    # richness of each branch.
    for composition_field in ("oneOf", "allOf", "anyOf"):
        for branch in get(schema, composition_field) or []:
            score += 1 + _schema_richness(branch, _depth + 1)
  • Files reviewed: 5/5 changed files
  • Comments generated: 3
  • Review effort level: Lite

Comment thread linodecli/baked/util.py
Comment on lines +62 to +64
array_items = get(schema, "items")
if array_items is not None:
score += _schema_richness(array_items, _depth + 1)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think we can apply this comment for the edge case

Comment thread linodecli/baked/response.py
Comment thread linodecli/baked/util.py

@yec-akamai yec-akamai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Tests passed locally!

@ezilber-akamai
ezilber-akamai merged commit 573ec3c into linode:dev Sep 16, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix for any bug fixes in the changelog. hotfix urgent fixes for production issues.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants