feat(sdk): add v3 Go client with typespec emitter#4675
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (6)
🚧 Files skipped from review as they are similar to previous changes (4)
📝 WalkthroughWalkthroughAdds a TypeSpec-based Go v3 SDK with generated models, services, transport, pagination, errors, documentation, and release automation. Migrates v3 e2e tests from legacy wrappers to the SDK and updates repository guidance, CI validation, and standalone-module workflows. ChangesGo SDK generation
Estimated code review effort: 5 (Critical) | ~120 minutes Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
c68ca3b to
a6024e1
Compare
5c67d52 to
4e498bf
Compare
|
Too many files changed for review. ( Bypass the limit by tagging |
There was a problem hiding this comment.
Actionable comments posted: 5
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
e2e/addons_v3_test.go (1)
218-235: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick winStale error messages reference old
Billing*type names.The
require.NoErrormessages on lines 219, 225, and 235 still sayBillingPriceFlat,BillingPriceUnit, andBillingPriceGraduated, but the v3 SDK types arePriceFlat,PriceUnit, andPriceGraduated. If these assertions fail, the messages will point to type names that no longer exist.✏️ Proposed fix for stale error messages
- flatPrice, err := gotFlat.Price.AsPriceFlat() - require.NoError(t, err, "flat price should decode as BillingPriceFlat") + flatPrice, err := gotFlat.Price.AsPriceFlat() + require.NoError(t, err, "flat price should decode as PriceFlat")- unitPrice, err := gotUnit.Price.AsPriceUnit() - require.NoError(t, err, "unit price should decode as BillingPriceUnit") + unitPrice, err := gotUnit.Price.AsPriceUnit() + require.NoError(t, err, "unit price should decode as PriceUnit")- gradPrice, err := gotGraduated.Price.AsPriceGraduated() - require.NoError(t, err, "graduated price should decode as BillingPriceGraduated") + gradPrice, err := gotGraduated.Price.AsPriceGraduated() + require.NoError(t, err, "graduated price should decode as PriceGraduated")🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@e2e/addons_v3_test.go` around lines 218 - 235, Update the require.NoError messages in the round-trip assertions after AsPriceFlat, AsPriceUnit, and AsPriceGraduated to use the current v3 type names PriceFlat, PriceUnit, and PriceGraduated instead of the obsolete BillingPrice* names.
🧹 Nitpick comments (4)
api/spec/packages/typespec-go/src/components/GoResource.tsx (1)
443-457: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueWrap the
defaultcase in a block to satisfy Biome'snoSwitchDeclarations.The
const mappeddeclaration at line 444 is in the switch's shared scope. Whiledefaultis the last case with areturn(so no actual bug), Biome flags it. The fix is a one-liner.♻️ Proposed fix
default: - const mapped = goType(program, parameter.type) - return ( - <go.StructMember - name={goExportedName(parameter.name)} - type={ - parameter.property.optional && !mapped.nilable ? ( - <go.Pointer>{mapped.type}</go.Pointer> - ) : ( - mapped.type - ) - } - /> - ) + { + const mapped = goType(program, parameter.type) + return ( + <go.StructMember + name={goExportedName(parameter.name)} + type={ + parameter.property.optional && !mapped.nilable ? ( + <go.Pointer>{mapped.type}</go.Pointer> + ) : ( + mapped.type + ) + } + /> + ) + } } }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@api/spec/packages/typespec-go/src/components/GoResource.tsx` around lines 443 - 457, Wrap the switch statement’s default case containing the mapped declaration and JSX return in braces, so const mapped is scoped to that case and satisfies Biome’s noSwitchDeclarations rule. Preserve the existing goType, goExportedName, and pointer/nilability logic unchanged.Source: Linters/SAST tools
e2e/planaddons_v3_test.go (1)
31-117: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd concise given/when/then comments to lifecycle subtests.
These non-trivial service/lifecycle subtests currently begin directly with setup and assertions. Adding brief
given/when/thenintent comments will make the scenarios easier to scan and preserve the repository’s test-structure convention.Also applies to: 188-205, 250-286, 293-333
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@e2e/planaddons_v3_test.go` around lines 31 - 117, Add concise Given/When/Then comments to each lifecycle subtest, including the shown plan/addon flow and the referenced ranges. Place comments before setup, service invocation, and assertions to identify the preconditions, action, and expected outcome while preserving the existing test logic.Source: Coding guidelines
api/v3/client/ptr.go (1)
11-27: 📐 Maintainability & Code Quality | 🔵 Trivial | 🏗️ Heavy liftAvoid generating package-local pointer wrappers.
Ptr,String,Int,Bool, andTimeviolate the repository rule against localptr-style helpers. Remove them from the emitter/runtime template and regenerate the SDK, updating generated call sites as needed.Based on learnings,
api/v3/clientis regenerable output and should be changed through the emitter or templates, not by hand-editing generated files.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@api/v3/client/ptr.go` around lines 11 - 27, Remove the local pointer helpers Ptr, String, Int, Bool, and Time from the emitter/runtime template that generates api/v3/client, then regenerate the SDK. Update generated call sites to use the repository-approved pointer mechanism or inline addressable values, ensuring no package-local ptr-style wrappers remain.Sources: Coding guidelines, Learnings
.github/workflows/release-go-sdk.yaml (1)
39-42: 🔒 Security & Privacy | 🔵 Trivial | 💤 Low valueConsider disabling setup-go cache for release workflow.
Static analysis flagged a potential cache-poisoning risk:
actions/setup-goenables caching by default. While the risk is low for a tag-push release workflow (tag pushes are typically restricted to maintainers), consider addingcache: falsefor defense-in-depth, since the release workflow should prioritize reproducibility over build speed.🔒️ Optional: disable cache in release workflow
- name: Set up Go uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6.5.0 with: go-version-file: api/v3/client/go.mod cache-dependency-path: api/v3/client/go.sum + cache: false🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In @.github/workflows/release-go-sdk.yaml around lines 39 - 42, Disable Go dependency caching in the setup-go step by adding the cache setting under the existing actions/setup-go configuration in the release workflow, while preserving the go-version-file and cache-dependency-path settings.Source: Linters/SAST tools
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.github/workflows/release-go-sdk.yaml:
- Around line 14-16: Replace the regex-style tag filters under the release
workflow’s `on.push.tags` configuration with GitHub Actions glob-compatible
patterns that match stable, `-dev`, and `-beta` SDK tags such as
`api/v3/client/v1.0.0`; alternatively, move precise version validation into a
job step.
In `@api/spec/packages/typespec-go/src/components/GoUnion.tsx`:
- Around line 33-38: Update GoUnion rendering to reject discriminated unions
containing any non-model variant: after computing discriminator in GoUnion,
detect variants that are not models and throw a clear error when discriminator
is set. Use the existing modelVariants/union variant data and ensure
GoModels.renderUnion cannot route unsupported mixed discriminated unions into
generated helpers.
In `@api/v3/client/query.go`:
- Around line 66-70: The Oeq and Ocontains serialization in the query emitter
must not ambiguously join values containing commas. Update the generator/runtime
template to either reject comma-containing values or apply the API-supported
escaping format, then regenerate api/v3/client so both filter paths use the
corrected behavior.
In `@api/v3/client/README.md`:
- Around line 191-192: Replace “cancelation” with the standard “cancellation”
spelling in the upstream TypeSpec/API description, including the relevant
UnscheduleCancelation symbol or documentation source, then regenerate
api/v3/client/README.md so the generated endpoint descriptions are updated
without editing the README directly.
In `@e2e/customer_credits_v3_test.go`:
- Around line 25-30: Update the test around Customers.Credits.Balance.Get to
have the test server capture and assert the raw timestamp query parameter
matches the valid timestamp sent in GetCustomerCreditBalanceParams,
independently of whether the request returns an error. Retain the existing API
error checks, but ensure a nil error cannot allow the test to pass without
verifying timestamp transmission.
---
Outside diff comments:
In `@e2e/addons_v3_test.go`:
- Around line 218-235: Update the require.NoError messages in the round-trip
assertions after AsPriceFlat, AsPriceUnit, and AsPriceGraduated to use the
current v3 type names PriceFlat, PriceUnit, and PriceGraduated instead of the
obsolete BillingPrice* names.
---
Nitpick comments:
In @.github/workflows/release-go-sdk.yaml:
- Around line 39-42: Disable Go dependency caching in the setup-go step by
adding the cache setting under the existing actions/setup-go configuration in
the release workflow, while preserving the go-version-file and
cache-dependency-path settings.
In `@api/spec/packages/typespec-go/src/components/GoResource.tsx`:
- Around line 443-457: Wrap the switch statement’s default case containing the
mapped declaration and JSX return in braces, so const mapped is scoped to that
case and satisfies Biome’s noSwitchDeclarations rule. Preserve the existing
goType, goExportedName, and pointer/nilability logic unchanged.
In `@api/v3/client/ptr.go`:
- Around line 11-27: Remove the local pointer helpers Ptr, String, Int, Bool,
and Time from the emitter/runtime template that generates api/v3/client, then
regenerate the SDK. Update generated call sites to use the repository-approved
pointer mechanism or inline addressable values, ensuring no package-local
ptr-style wrappers remain.
In `@e2e/planaddons_v3_test.go`:
- Around line 31-117: Add concise Given/When/Then comments to each lifecycle
subtest, including the shown plan/addon flow and the referenced ranges. Place
comments before setup, service invocation, and assertions to identify the
preconditions, action, and expected outcome while preserving the existing test
logic.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 12f23a56-4542-48db-afef-008c1347d30d
⛔ Files ignored due to path filters (4)
api/spec/pnpm-lock.yamlis excluded by!**/pnpm-lock.yamlapi/v3/client/go.modis excluded by!**/*.modapi/v3/client/go.sumis excluded by!**/*.sum,!**/*.sumgo.modis excluded by!**/*.mod
📒 Files selected for processing (113)
.agents/skills/e2e/SKILL.md.gitattributes.github/workflows/ci.yaml.github/workflows/release-go-sdk.yamlAGENTS.mdDockerfileMakefileapi/spec/.prettierignoreapi/spec/AGENTS.mdapi/spec/package.jsonapi/spec/packages/aip/package.jsonapi/spec/packages/aip/tspconfig.yamlapi/spec/packages/typespec-go/.gitignoreapi/spec/packages/typespec-go/README.mdapi/spec/packages/typespec-go/package.jsonapi/spec/packages/typespec-go/src/components/GoClient.tsxapi/spec/packages/typespec-go/src/components/GoEnum.tsxapi/spec/packages/typespec-go/src/components/GoModels.tsxapi/spec/packages/typespec-go/src/components/GoResource.tsxapi/spec/packages/typespec-go/src/components/GoStruct.tsxapi/spec/packages/typespec-go/src/components/GoTypeSpecEnum.tsxapi/spec/packages/typespec-go/src/components/GoUnion.tsxapi/spec/packages/typespec-go/src/emitter.tsxapi/spec/packages/typespec-go/src/go-types.tsxapi/spec/packages/typespec-go/src/grouping.tsapi/spec/packages/typespec-go/src/index.tsapi/spec/packages/typespec-go/src/lib.tsapi/spec/packages/typespec-go/src/operations.tsapi/spec/packages/typespec-go/src/projections.tsapi/spec/packages/typespec-go/src/readme.tsapi/spec/packages/typespec-go/src/runtime-symbols.tsapi/spec/packages/typespec-go/src/runtime-templates.tsapi/spec/packages/typespec-go/src/stdlib.tsapi/spec/packages/typespec-go/test/assembly.test.tsapi/spec/packages/typespec-go/test/go-types.test.tsapi/spec/packages/typespec-go/test/operations.test.tsapi/spec/packages/typespec-go/test/projections.test.tsapi/spec/packages/typespec-go/test/resource-render.test.tsapi/spec/packages/typespec-go/tsconfig.jsonapi/v3/client/README.mdapi/v3/client/addons.goapi/v3/client/apps.goapi/v3/client/billing.goapi/v3/client/client.goapi/v3/client/currencies.goapi/v3/client/customers.goapi/v3/client/customers_billing.goapi/v3/client/customers_charges.goapi/v3/client/customers_credits.goapi/v3/client/customers_credits_adjustments.goapi/v3/client/customers_credits_balance.goapi/v3/client/customers_credits_grants.goapi/v3/client/customers_credits_transactions.goapi/v3/client/defaults.goapi/v3/client/doc.goapi/v3/client/entitlements.goapi/v3/client/errors.goapi/v3/client/errors_test.goapi/v3/client/events.goapi/v3/client/features.goapi/v3/client/filters.goapi/v3/client/governance.goapi/v3/client/invoices.goapi/v3/client/llm_cost.goapi/v3/client/meters.goapi/v3/client/models_addons.goapi/v3/client/models_apps.goapi/v3/client/models_billing.goapi/v3/client/models_currencies.goapi/v3/client/models_customers.goapi/v3/client/models_defaults.goapi/v3/client/models_entitlements.goapi/v3/client/models_events.goapi/v3/client/models_features.goapi/v3/client/models_governance.goapi/v3/client/models_invoices.goapi/v3/client/models_llm_cost.goapi/v3/client/models_meters.goapi/v3/client/models_plan_addons.goapi/v3/client/models_plans.goapi/v3/client/models_shared.goapi/v3/client/models_subscriptions.goapi/v3/client/models_tax.goapi/v3/client/nullable.goapi/v3/client/one_or_many.goapi/v3/client/option.goapi/v3/client/pagination.goapi/v3/client/pagination_test.goapi/v3/client/plan_addons.goapi/v3/client/plans.goapi/v3/client/ptr.goapi/v3/client/query.goapi/v3/client/request_content_type.goapi/v3/client/subscriptions.goapi/v3/client/tax.goapi/v3/client/transport.goapi/v3/client/transport_test.goapi/v3/client/types.gobenthos-collector.Dockerfilee2e/addons_v3_test.goe2e/billinginvoice_override_test.goe2e/billinginvoice_unitconfig_test.goe2e/billinginvoices_v3_test.goe2e/customer_credits_v3_test.goe2e/e2e_test.goe2e/governance_bench_test.goe2e/helpers.goe2e/plan_entitlement_template_v3_test.goe2e/planaddons_v3_test.goe2e/plans_v3_test.goe2e/productcatalog_smoke_v3_test.goe2e/subscriptionaddons_v3_test.goe2e/v3helpers_test.go
💤 Files with no reviewable changes (1)
- e2e/helpers.go
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.github/workflows/release-go-sdk.yaml:
- Around line 15-22: Replace the regex-style tag filters under the workflow’s
on.push.tags with GitHub Actions glob patterns such as v*.*.* so version tags
trigger correctly. Add a validation step before the release job to enforce the
exact stable, dev, or beta version format using the proposed regex and fail with
a clear message for invalid tags.
In `@AGENTS.md`:
- Around line 57-58: Update the make mod target to run module maintenance for
api/v3/client in addition to the root, collector, and e2e modules, preserving
the existing commands and error handling. Verify AGENTS.md remains accurate
after the target change.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 9c425e18-5994-4abd-8277-fa317be14d5a
⛔ Files ignored due to path filters (2)
e2e/go.modis excluded by!**/*.mode2e/go.sumis excluded by!**/*.sum,!**/*.sum
📒 Files selected for processing (10)
.agents/skills/e2e/SKILL.md.github/workflows/release-go-sdk.yamlAGENTS.mdMakefileapi/spec/packages/typespec-go/README.mdapi/spec/packages/typespec-go/src/emitter.tsxapi/spec/packages/typespec-go/src/lib.tsapi/spec/packages/typespec-go/src/runtime-templates.tsapi/spec/packages/typespec-go/test/assembly.test.tsapi/v3/client/option.go
✅ Files skipped from review due to trivial changes (1)
- api/spec/packages/typespec-go/README.md
🚧 Files skipped from review as they are similar to previous changes (4)
- .agents/skills/e2e/SKILL.md
- api/spec/packages/typespec-go/test/assembly.test.ts
- api/spec/packages/typespec-go/src/runtime-templates.ts
- api/spec/packages/typespec-go/src/emitter.tsx
- disable setup-go caching in the SDK release workflow (zizmor cache-poisoning gate) - cover api/v3/client in make mod and make lint-go - fail fast on discriminated unions with non-model variants in typespec-go - add wire-level query serialization tests for filters and scalar params
7a50915 to
eab2fe4
Compare
Greptile Summary
This PR adds a generated v3 Go SDK and the TypeSpec emitter that produces it. The main changes are:
@openmeter/typespec-goemitter package underapi/spec.api/v3/client.Confidence Score: 5/5
This looks safe to merge.
Important Files Changed
Reviews (15): Last reviewed commit: "feat(sdk): add v3 Go client with typespe..." | Re-trigger Greptile
Context used (3)
Summary by CodeRabbit
New Features
/api/v3/...endpoints.Testing
Chores