Skip to content
This repository was archived by the owner on Jun 2, 2026. It is now read-only.

fix: Correct AuditEntry queryParams/body types in OpenAPI spec#592

Merged
kunzhao-nv merged 2 commits into
mainfrom
fix/audit-entry-spec-types
Jun 1, 2026
Merged

fix: Correct AuditEntry queryParams/body types in OpenAPI spec#592
kunzhao-nv merged 2 commits into
mainfrom
fix/audit-entry-spec-types

Conversation

@kunzhao-nv

@kunzhao-nv kunzhao-nv commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

Description

AuditEntry.queryParams and AuditEntry.body were declared as type: string in openapi/spec.yaml, but the Go API model, DB model, and audit middleware all use url.Values (= map[string][]string) and map[string]interface{} respectively, so the wire shape on GET /audit is a JSON object, not a stringified JSON.

Regenerate docs/index.html and sdk/standard/ accordingly.

Type of Change

  • Feature - New feature or functionality (feat:)
  • Fix - Bug fixes (fix:)
  • Chore - Modification or removal of existing functionality (chore:)
  • Refactor - Refactoring of existing functionality (refactor:)
  • Docs - Changes in documentation or OpenAPI schema (docs:)
  • CI - Changes in GitHub workflows. Requires additional scrutiny (ci:)
  • Version - Issuing a new release version (version:)

Services Affected

  • API - API models or endpoints updated
  • Workflow - Workflow service updated
  • DB - DB DAOs or migrations updated
  • Site Manager - Site Manager updated
  • Cert Manager - Cert Manager updated
  • Site Agent - Site Agent updated
  • Flow - Flow service updated
  • Powershelf Manager - Powershelf Manager updated
  • NVSwitch Manager - NVSwitch Manager updated

Related Issues (Optional)

Breaking Changes

  • This PR contains breaking changes

Testing

  • Unit tests added/updated
  • Integration tests added/updated
  • Manual testing performed
  • No testing required (docs, internal refactor, etc.)

Additional Notes

`AuditEntry.queryParams` is `url.Values` (`map[string][]string`) and
`AuditEntry.body` is `map[string]interface{}` in both the API model
(`api/pkg/api/model/audit_entry.go`) and the DB model
(`db/pkg/db/model/audit_entry.go` — both jsonb). The audit middleware
also unmarshals the raw request body into a `map[string]interface{}`
before persisting (`api/pkg/middleware/audit.go`), so the wire shape
on `GET /audit` is a JSON object, not a string.

The spec, however, declared both fields as `type: string` with examples
written as stringified JSON (e.g. `'{"key1":"value1"}'`). That produced
a generated Go SDK whose `AuditEntry.Body` and `QueryParams` were
`*string`, which silently failed to unmarshal real responses.

Realign the schema with the implementation:

- `queryParams`: `type: object` with `additionalProperties: {type: array,
  items: {type: string}}` — mirrors `url.Values` exactly.
- `body`: `type: object` — free-form JSON, with a note on the
  sensitive-field obfuscation the middleware performs.
- Update both inline endpoint examples and the schema-level example to
  use nested objects instead of stringified JSON, which also clears the
  Redocly `no-invalid-media-type-examples` warnings on these paths.

`extraData` was already `type: object`, so it is unchanged.

Run `make publish-openapi && make generate-sdk` and commit the updated
`docs/index.html` and `sdk/standard/` in a follow-up commit.

Signed-off-by: Kun Zhao <kunzhao@nvidia.com>
Output of `make publish-openapi && make generate-sdk` against the
AuditEntry spec fix in the previous commit.

`sdk/standard/model_audit_entry.go` is the substantive change: `Body`
and `QueryParams` flip from `*string` to `map[string]interface{}` and
`map[string][]string` respectively, matching the wire shape that the
API server already produces.

The rest of `sdk/standard/` and `docs/index.html` is generator-version
drift from previous PRs that did not rerun the regen targets — most of
it is whitespace/alignment that `gofmt` normalises, a couple of fields
gaining descriptions that were always present in the spec, and a
`defer file.Close()` swap in the generated client. None of these
require source changes; they are simply the artifacts catching up to
their inputs. CI was going to flag them as stale on the next regen
either way.

The handful of non-SDK file changes (`flow/internal/task/...`,
`common/pkg/util/converter_test.go`) are SPDX-header style fixes from
`scripts/check_source_headers.py --fix`, which the `generate-sdk`
target runs and which normalises any file still using the old
multi-line `/* … */` SPDX block to the two-line `//` form adopted in
b7b0cc4 ("chore: Switch file headers to two-line SPDX license style").
These files were added after b7b0cc4 and slipped through. Folding
them in here so the next `make generate-sdk` run produces no diff.

Signed-off-by: Kun Zhao <kunzhao@nvidia.com>
@kunzhao-nv kunzhao-nv requested a review from a team as a code owner June 1, 2026 05:32
@copy-pr-bot

copy-pr-bot Bot commented Jun 1, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@coderabbitai

coderabbitai Bot commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

This pull request modernizes the SDK and OpenAPI specifications through four distinct technical changes: administrative licensing updates, API contract evolution, data model type refinement, and systematic pagination behavior correction across 27 endpoints.

Changes

SDK and API Specification Modernization

Layer / File(s) Summary
SPDX License Header Standardization
common/pkg/util/converter_test.go, flow/internal/task/componentmanager/compute/nico/config.go, flow/internal/task/componentmanager/config/manager_config.go, flow/internal/task/message/message.go, flow/internal/task/operations/summary.go, flow/internal/task/operations/summary_test.go, flow/internal/task/report/report.go
Replace multi-line Apache 2.0 license blocks with concise SPDX-style headers across 7 files. Purely administrative change with no functional impact.
OpenAPI Request Schema Modernization
openapi/spec.yaml
Evolve queryParams and body fields from stringified JSON representations to structured object types. Schema now reflects queryParams as object with additionalProperties of string arrays, and body as parsed object instead of string. Examples updated consistently across multiple request signatures.
AuditEntry Data Model Type Restructuring
sdk/standard/model_audit_entry.go
Restructure AuditEntry by changing QueryParams from *string to map[string][]string and Body from *string to map[string]interface{}. Update all 8 accessor method signatures (Get, GetOk, Set variants) to work with structured map types, aligning with OpenAPI schema modernization.
SDK API Pagination Query Parameter Wiring
sdk/standard/api_allocation.go, api_audit.go, api_dpu_extension_service.go, api_expected_machine.go, api_expected_power_shelf.go, api_expected_rack.go, api_expected_switch.go, api_infini_band_partition.go, api_instance.go, api_instance_type.go, api_ip_block.go, api_machine.go, api_network_security_group.go, api_nv_link_logical_partition.go, api_operating_system.go, api_rack.go, api_site.go, api_sku.go, api_ssh_key.go, api_ssh_key_group.go, api_subnet.go, api_tenant_account.go, api_tray.go, api_vpc.go, api_vpc_peering.go, api_vpc_prefix.go
Ensure default pageNumber=1 is explicitly added to localVarQueryParams when request field is nil across 27 Execute methods. Previously, default was only assigned to r.pageNumber without populating the outgoing query string. Some endpoints also default activeOnly parameter (api_rack.go, api_tray.go). Consistent behavioral fix with repetitive pattern implementation.
SDK Model Struct Field Alignment and Comments
sdk/standard/model_expected_machine.go, model_expected_machine_create_request.go, model_expected_machine_update_request.go, model_expected_power_shelf.go, model_expected_power_shelf_create_request.go, model_expected_power_shelf_update_request.go, model_expected_rack.go, model_expected_rack_create_request.go, model_expected_rack_update_request.go, model_expected_switch.go, model_expected_switch_create_request.go, model_expected_switch_update_request.go, model_infini_band_partition.go, model_infini_band_partition_create_request.go, model_infini_band_partition_update_request.go, model_instance_update_request.go, model_machine_update_request.go, model_vpc.go, model_vpc_create_request.go, model_vpc_update_request.go
Reformat struct field declarations across 23 model files with whitespace/alignment adjustments. HostId, Description, and Labels fields realigned. InfiniBandPartition.Labels receives descriptive comment ("String key value pairs, up to 10 pairs"). No JSON tags, field types, or serialization behavior changed.
SDK Client Resource Management
sdk/standard/client.go
Simplify file handle cleanup in addFile from explicit file.Close() with error return to defer file.Close(). Removes redundant error handling on close operation.

Sequence Diagram

sequenceDiagram
  participant Client as SDK Client
  participant Execute as GetAllXxxExecute
  participant Query as parameterAddToHeaderOrQuery
  participant Params as localVarQueryParams
  Client->>Execute: ApiGetAllXxxRequest(pageNumber=nil)
  Execute->>Execute: r.pageNumber == nil?
  Execute->>Query: pageNumber, defaultValue(1)
  Query->>Params: Add pageNumber=1
  Params-->>Execute: Updated query parameters
  Execute->>Execute: r.pageNumber = &defaultValue
  Execute-->>Client: HTTP GET ?pageNumber=1&...
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the primary change: correcting the OpenAPI spec declarations for AuditEntry.queryParams and AuditEntry.body types.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed The PR description accurately describes the changeset: correcting AuditEntry queryParams/body types in OpenAPI spec from strings to structured objects, with corresponding Go SDK regeneration.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/audit-entry-spec-types

Comment @coderabbitai help to get the list of available commands and usage tips.

@kunzhao-nv kunzhao-nv requested a review from thossain-nv June 1, 2026 05:32
@github-actions

github-actions Bot commented Jun 1, 2026

Copy link
Copy Markdown

Test Results

9 821 tests  ±0   9 821 ✅ ±0   7m 32s ⏱️ +33s
  161 suites ±0       0 💤 ±0 
   14 files   ±0       0 ❌ ±0 

Results for commit 89e6a76. ± Comparison against base commit 0451d4c.

@thossain-nv thossain-nv 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.

Thanks @kunzhao-nv

@kunzhao-nv kunzhao-nv merged commit 72c00aa into main Jun 1, 2026
58 checks passed
@kunzhao-nv kunzhao-nv deleted the fix/audit-entry-spec-types branch June 1, 2026 16:48
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants