Skip to content

fix: populate okta_app_oauth type on import for preconfigured OIN OIDC apps (GH-2868) - #2870

Open
exitcode0 wants to merge 5 commits into
okta:masterfrom
exitcode0:fix/app-oauth-preconfigured-import-type
Open

fix: populate okta_app_oauth type on import for preconfigured OIN OIDC apps (GH-2868)#2870
exitcode0 wants to merge 5 commits into
okta:masterfrom
exitcode0:fix/app-oauth-preconfigured-import-type

Conversation

@exitcode0

@exitcode0 exitcode0 commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Fixes #2868.

Problem

Importing a preconfigured OIN OIDC app into okta_app_oauth leaves the type attribute empty in state. Because type is Required + ForceNew, the next terraform plan shows type = "web" # forces replacement and plans to destroy/recreate the live app, so existing OIN OIDC apps (e.g. ISPM, Okta Privileged Access) can't be imported cleanly. This is the import half left unaddressed by #2721 / #1030 (preconfigured_app create support, v6.7.0).

Root cause

On Read, type was set only inside setOAuthClientSettingsV6, which early-returns when settings.oauthClient is nil. For preconfigured OIN apps the public GET /apps/{id} can omit oauthClient (nil) and/or application_type (empty), so type was never populated.

Fix

Move type population into a dedicated setOAuthAppType helper invoked from resourceAppOAuthRead independent of the nil-oauthClient early-return. It only writes type when application_type is present and otherwise preserves the existing state/config value, so it never clobbers the ForceNew attribute with an empty string. type remains Required + ForceNew (it is genuinely immutable in Okta).

Tests

Added in-package unit test TestSetOAuthAppType covering nil oauthClient, empty application_type, and concrete-value cases. go build, go vet, gofmt, and the new unit test all pass. Acceptance tests (TF_ACC) require a live org and were not run.

…C apps

The okta_app_oauth Read path set the Required + ForceNew "type" attribute
only inside setOAuthClientSettingsV6, which early-returns when
settings.oauthClient is nil. For preconfigured OIN OIDC apps Okta's public
GET /apps/{id} can omit oauthClient (nil pointer) or its application_type,
so "type" was left empty in state. The next plan then rendered
`type = "..." # forces replacement` and planned to destroy and recreate the
live app, making OIN OIDC apps (e.g. ISPM, Okta Privileged Access)
impossible to import cleanly.

Move type population into a dedicated setOAuthAppType helper that runs in
Read regardless of the nil-oauthClient early-return and never clobbers a
known type with an empty value, so post-import plans are a no-op.

oktaGH-2868
@github-actions
github-actions Bot requested a review from dhiwakar-okta June 25, 2026 10:33
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.

okta_app_oauth: preconfigured OIDC import forces replace — type not read back

1 participant