Skip to content

HYBIM-853 Bug fix for openapi upgrade#72

Open
shuningc wants to merge 2 commits into
mainfrom
HYBIM-853-bug-fix
Open

HYBIM-853 Bug fix for openapi upgrade#72
shuningc wants to merge 2 commits into
mainfrom
HYBIM-853-bug-fix

Conversation

@shuningc

@shuningc shuningc commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Fix scripts/patch_http_validation_error.py to match the 0.29.0 generator's from_dict shape (_LOOP_RE rewritten; _loop_replacement updated to emit list[ValidationError] | Unset style
    without Union)
  • Regenerate src/splunk_ao/resources/ (1136 files) with openapi-python-client 0.29.0 — legitimate changes are Google-style docstrings, from future import annotations, response variable
    naming, and union reordering
  • Restore metric_key_alias to openapi.yaml's ColumnInfo schema — the field was missing from the spec but is returned by the API and used throughout shared/column.py and experiment.py;
    0.29.0's stricter generation dropped it, breaking 5 tests

What was broken before this PR

Commit e121f41 (HYBIM-777) bumped openapi-python-client to 0.29.0 in pyproject.toml/poetry.lock but never regenerated the client. As a result:

  1. The committed src/splunk_ao/resources/ was stale 0.26.x output
  2. The patch script's regex no longer matched 0.29.0's from_dict shape — running the regen would silently drop the isinstance-guarded string-detail 422 fix and reintroduce a crash

Verification

  • ./scripts/auto-generate-api-client.sh exits 0 ✅
  • Second run produces zero diff (idempotent) ✅
  • isinstance(_detail, list) guard confirmed present in http_validation_error.py ✅
  • Generator warnings unchanged vs 0.26.x baseline (pre-existing spec issues only) ✅
  • All imports resolve to splunk_ao.* (208 files confirmed) ✅
  • Full test suite: 1817 passed, 11 skipped, 0 failures ✅

Test plan

  • Run ./scripts/auto-generate-api-client.sh locally and confirm exit 0
  • Run poetry install --all-extras && poetry run pytest and confirm no failures
  • Grep src/splunk_ao/resources/models/http_validation_error.py for isinstance(_detail, list)

shuningc and others added 2 commits July 8, 2026 16:39
…i-python-client 0.29.0

- Rewrite _LOOP_RE in patch_http_validation_error.py to match 0.29.0
  from_dict shape (_detail pop before type annotation, if _detail is not
  UNSET wrapper, loop without or [])
- Update _loop_replacement to emit list[...] | Unset style (no Union)
- Regenerate all 1136 files under src/splunk_ao/resources/ with 0.29.0
  (Google-style docstrings, from __future__ import annotations, response
  variable naming, union reordering)
- Confirmed patch re-applied: isinstance(_detail, list) guard present in
  http_validation_error.py
- Confirmed generator warnings unchanged vs 0.26.x baseline (spec-level
  issues only, out of scope)

Co-Authored-By: Claude <noreply@anthropic.com>
@shuningc shuningc requested a review from pradystar July 9, 2026 00:15

@fercor-cisco fercor-cisco left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🤖 This review was generated by the Astra agent (claude-opus-4-8). It may contain mistakes.

Verdict: request_changes — Patch script and validation-error fix are correct and tested; but the manual metric_key_alias edit to the generated openapi.yaml is not durable and will be lost on the next spec import.

Follow-ups

Suggested follow-up work that could be tracked as Shortcut stories:

  • scripts/patch_http_validation_error.py:54-64: The patch script itself has no unit test. Given its regex is tightly coupled to the generator's exact output (and already broke silently on the 0.26.x -> 0.29.0 bump), a small pytest that feeds a representative 0.29.0 from_dict snippet through patch() and asserts the isinstance-guarded result — plus an idempotency case — would catch future generator drift in CI rather than at regen time.

Comment thread openapi.yaml
Comment on lines +11842 to +11850
metric_key_alias:
anyOf:
- type: string
- type: 'null'
title: Metric Key Alias
description: Alternate metric key for this column. When scorer UUIDs are used
as column IDs (e.g. "metrics/{uuid}"), this holds the legacy snake_case
metric name (e.g. "correctness") for display and dual-key query fallback.
None for non-metric columns.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🟠 major (design): This metric_key_alias field is added by hand-editing openapi.yaml, but openapi.yaml is a generated artifact: scripts/import-openapi-yaml.sh regenerates it from the live server's openapi.json. Because the server spec does not include metric_key_alias on the ColumnInfo schema, the next run of import-openapi-yaml.sh will overwrite this file and silently drop the field again — reintroducing the exact 5 test failures this PR is fixing. This is the same "lost patch on regeneration" failure mode the PR is otherwise hardening against for the HTTPValidationError patch.

The durable location for local spec fixups is the yq patch block in scripts/import-openapi-yaml.sh (see the existing precedent there: StepType.enum += ["control"], with the comment "server omits this value from the spec but returns it" and "add the openapi.yaml patches here"). Please add the metric_key_alias injection to that yq expression (e.g. set .components.schemas.ColumnInfo.properties.metric_key_alias) so it survives a spec re-import. Note LogRecordsColumnInfo and the metric_* schemas already carry the field in the server spec, so only ColumnInfo needs the manual patch.

🤖 Generated by the Astra agent

Comment thread openapi.yaml
title: Roll Up Method
description: Default roll-up aggregation method for this metric (e.g., 'sum',
'average').
metric_key_alias:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Manually adding code to this file will not work. These edits will be lost on the next automated update.

If changes are necessary in Galileo's api definition that needs to be done on https://github.com/rungalileo/api

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.

2 participants