Skip to content

fix(management_api): CreateUserIdentity response decodes identity_id … - #60

Closed
BrandtKruger wants to merge 3 commits into
kinde-oss:mainfrom
BrandtKruger:CreateUserIdentity
Closed

fix(management_api): CreateUserIdentity response decodes identity_id …#60
BrandtKruger wants to merge 3 commits into
kinde-oss:mainfrom
BrandtKruger:CreateUserIdentity

Conversation

@BrandtKruger

Copy link
Copy Markdown
Contributor

CreateUserIdentity response decodes identity_id from API

When creating an identity with an existing enterprise identity, the Kinde API returns identity_id instead of id. Add local OpenAPI spec with identity_id and regenerate SDK so the decoder accepts both; add EffectiveIdentityID() helper.

  • Add spec/kinde-management-api-spec.yaml (from api-spec.kinde.com) with identity_id on create_identity_response.identity
  • Update generate.go to use local spec
  • Regenerate management_api (ogen) so CreateIdentityResponseIdentity has ID and IdentityID; decoder handles both JSON keys
  • Add create_identity_response_helpers.go with EffectiveIdentityID()
  • Add create_identity_response_test.go for id and identity_id decode paths

Explain your changes

Suppose there is a related issue with enough detail for a reviewer to understand your changes fully. In that case, you can omit an explanation and instead include either “Fixes #XX” or “Updates #XX” where “XX” is the issue number.

Checklist

🛟 If you need help, consider asking for advice over in the Kinde community.

…from API

When creating an identity with an existing enterprise identity, the Kinde
API returns identity_id instead of id. Add local OpenAPI spec with identity_id
and regenerate SDK so the decoder accepts both; add EffectiveIdentityID() helper.

- Add spec/kinde-management-api-spec.yaml (from api-spec.kinde.com) with
  identity_id on create_identity_response.identity
- Update generate.go to use local spec
- Regenerate management_api (ogen) so CreateIdentityResponseIdentity has
  ID and IdentityID; decoder handles both JSON keys
- Add create_identity_response_helpers.go with EffectiveIdentityID()
- Add create_identity_response_test.go for id and identity_id decode paths

Co-authored-by: Cursor <cursoragent@cursor.com>
@BrandtKruger
BrandtKruger requested a review from a team as a code owner February 14, 2026 12:07
@coderabbitai

coderabbitai Bot commented Feb 14, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@BrandtKruger has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 11 minutes and 7 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

Walkthrough

This PR fixes a typo in the Delete API application-scope operation name across generated server/client/handler code, adds optional/nullable JSON wrapper types and encoding/decoding logic, extends schemas with billing, API-scopes, and organization sign-in fields, adds query parameters (active_since, api_scopes), and introduces an EffectiveIdentityID helper with tests.

Changes

Cohort / File(s) Summary
Identity helper & tests
kinde/management_api/create_identity_response_helpers.go, kinde/management_api/create_identity_response_test.go
Added EffectiveIdentityID() (string, bool) on CreateIdentityResponseIdentity with nil/empty handling and comprehensive tests covering id, identity_id, and precedence scenarios.
Generation config
kinde/management_api/generate.go
Updated go:generate to use local spec spec/kinde-management-api-spec.yaml instead of external URL.
Typo rename: DeleteAPIApplicationScope
kinde/management_api/oas_client_gen.go, kinde/management_api/oas_handlers_gen.go, kinde/management_api/oas_interfaces_gen.go, kinde/management_api/oas_operations_gen.go, kinde/management_api/oas_parameters_gen.go, kinde/management_api/oas_response_decoders_gen.go, kinde/management_api/oas_response_encoders_gen.go, kinde/management_api/oas_router_gen.go, kinde/management_api/oas_security_gen.go, kinde/management_api/oas_server_gen.go, kinde/management_api/oas_unimplemented_gen.go
Renamed types, methods, constants, decode/encode functions, handlers, router operation IDs, and security map keys to correct DeleteAPIApplicationScope spelling; updated signatures and propagated changes across generated call sites.
JSON optional/nullable support
kinde/management_api/oas_json_gen.go
Replaced many direct fields with optional wrappers (OptBool, OptString, OptInt, OptUUID, etc.), added Encode/Decode/MarshalJSON/UnmarshalJSON for wrappers and enums, and introduced encodeFields() logic to handle Set/Null semantics during serialization/deserialization.
Query parameters & param decoding
kinde/management_api/oas_parameters_gen.go
Added ActiveSince (OptNilDateTime) and APIScopes (OptNilString) to GetUsersParams and APIScopes to SearchUsersParams; updated unpack/decode functions and imports (added time) to parse active_since and api_scopes. Also renamed DeleteAPIAppliationScopeParamsDeleteAPIApplicationScopeParams.
Schema additions & accessors
kinde/management_api/oas_schemas_gen.go
Added CreateApiKeyReqType enum and Type to CreateApiKeyReq; added IdentityID on CreateIdentityResponseIdentity; introduced UserBilling + OptUserBilling and Billing on User/response items; added IsSuspended to OrganizationUser; added LastOrganizationSignIns types; added APIScopes item types across user responses; removed some SAML ACS fields and expanded SAML strategy enum values.
Validators
kinde/management_api/oas_validators_gen.go
Added CreateApiKeyReqType.Validate() and integrated it into CreateApiKeyReq.Validate(); extended SAML strategy validation values; updated UpdateOrganizationSessionsReqSSOSessionPersistenceMode accepted value; added UsersResponse and UsersResponseUsersItem validators for new nested fields.
Response encoder/decoder behavior
kinde/management_api/oas_response_decoders_gen.go, kinde/management_api/oas_response_encoders_gen.go
Removed handling for a 204 No Content case in AddOrganizationUsers; introduced validation call after decoding in some response paths; renamed encode/decode functions and response types for the corrected Delete API application-scope operation.
Changelog
CHANGELOG.md
Added Unreleased section noting the typo fix rename for delete API application scope response types.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

🚥 Pre-merge checks | ✅ 3 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 36.36% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: fixing the CreateUserIdentity response to decode the identity_id field from the API.
Description check ✅ Passed The description is fully related to the changeset, explaining why the change was needed, what files were added/modified, and the overall objective of supporting both id and identity_id fields.
Merge Conflict Detection ✅ Passed ✅ No merge conflicts detected when merging into main

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

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@kinde/management_api/oas_schemas_gen.go`:
- Around line 4180-4195: The rename corrected DeleteAPIAppliationScope* →
DeleteAPIApplicationScope* is breaking; restore backward compatibility by adding
type aliases for the old misspelled symbols (e.g., alias
DeleteAPIAppliationScopeBadRequest, DeleteAPIAppliationScopeForbidden,
DeleteAPIAppliationScopeOK, DeleteAPIAppliationScopeTooManyRequests to the new
DeleteAPIApplicationScopeBadRequest, DeleteAPIApplicationScopeForbidden,
DeleteAPIApplicationScopeOK, DeleteAPIApplicationScopeTooManyRequests
respectively) in a separate non-generated compatibility file (or near the
generated types) and also add a clear entry in the changelog/release notes
documenting the rename so downstream consumers can update their imports.
🧹 Nitpick comments (2)
kinde/management_api/oas_json_gen.go (1)

23690-23708: Minor: value assigned before error check in generated allowed_domains decoder.

Lines 23695–23697 assign elem = string(v) before checking err. While not a runtime bug (elem isn't used on the error path), this deviates from the typical ogen pattern where the error check precedes the assignment. Since this is generated code, this is likely an ogen quirk — but worth noting if the generator is configurable.

v, err := d.Str()
elem = string(v)  // assigned before err check
if err != nil {
    return err
}
kinde/management_api/oas_parameters_gen.go (1)

1487-1522: Consider a backward‑compatibility alias for the renamed params type.
Fixing the typo in an exported type can break downstream code; if this isn’t a major release, add a type alias in a non‑generated file to preserve compatibility.

Comment thread kinde/management_api/oas_schemas_gen.go
Co-authored-by: Cursor <cursoragent@cursor.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@CHANGELOG.md`:
- Around line 3-7: Update the changelog to document the new feature: add an
entry under "Unreleased" (e.g., a "Features" or "Enhancements" subsection)
describing that CreateUserIdentity responses now include identity_id handling
and that a new helper method EffectiveIdentityID() was added to extract/resolve
the effective identity ID; mention any breaking or usage notes for callers that
should use EffectiveIdentityID() to obtain the identity ID. Include the feature
title and brief description alongside the existing typo fix entry so users see
both changes.

Comment thread CHANGELOG.md
…ty_id fix

Co-authored-by: Cursor <cursoragent@cursor.com>
@dtoxvanilla1991

dtoxvanilla1991 commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Closing this in favor of #62. The new PR drops the full vendored-spec SDK regen in favor of a small, targeted patch step, avoiding the unrelated breaking changes that got pulled in here.

Thanks for the fix, Brandt!

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