Skip to content

fix(shim): resolve real org version instead of hardcoded 9.2.0.0 fallback - #168

Merged
TomProkop merged 1 commit into
masterfrom
fix/connected-org-version-external-token-management
Jul 3, 2026
Merged

fix(shim): resolve real org version instead of hardcoded 9.2.0.0 fallback#168
TomProkop merged 1 commit into
masterfrom
fix/connected-org-version-external-token-management

Conversation

@TomProkop

@TomProkop TomProkop commented Jul 3, 2026

Copy link
Copy Markdown
Member

Problem

CrmServiceClient (our Microsoft.Xrm.Tooling.Connector.CrmServiceClient-compatible shim over Microsoft.PowerPlatform.Dataverse.Client.ServiceClient) hardcoded ConnectedOrgVersion to 9.2.0.0 whenever the base SDK returned its own stub default of 9.0.0.0 — which happens under the token-provider (ExternalTokenManagement) constructor path used by CmtImportRunner, CmtExportRunner, and PackageDeployerRunner.

9.2.0.0 is below CMT's UpsertMultiple batch-mode version gate (9.2.23083.00120), so the Configuration Migration Tool import path silently fell back to slow, one-by-one Create/Update calls through our wrapper — regardless of how modern the real connected org actually is.

Root cause

The underlying SDK's ExternalTokenManagement auth path sets OrganizationVersion = 9.0.0.0 at connect time and skips normal server-version discovery. This was previously worked around (see history of this file) by hardcoding a fallback constant, after earlier attempts using RetrieveVersion/OrganizationDetail were believed to fail silently in that auth mode.

That belief no longer holds for the SDK version we consume (1.2.10) — confirmed live against a real Dataverse online environment (actual org version 9.2.26061.150):

  • ConnectedOrgVersion initially reports the SDK's stub default 9.0.0.0.
  • ServiceClient.OrganizationDetail (public property, forces a real RefreshInstanceDetails) correctly returns the real version (9.2.26061.150).
  • Execute(new RetrieveVersionRequest()) also correctly returns the real version.

Filed upstream for the SDK-level bug: microsoft/PowerPlatform-DataverseServiceClient#538

Fix

Replaced the hardcoded 9.2.0.0 constant in CrmServiceClient.ConnectedOrgVersion with a cascade using only public SDK APIs:

  1. Base property (fast path, in case already populated).
  2. OrganizationDetail (forces a real refresh).
  3. Execute(new RetrieveVersionRequest()) (last resort, strongly-typed request).

If every mechanism still returns the SDK default, the base value is returned honestly instead of substituting a hardcoded constant.

Related

…back

CrmServiceClient's ConnectedOrgVersion hardcoded a 9.2.0.0 fallback whenever
the base ServiceClient returned its own default of 9.0.0.0, which happens
under the token-provider (ExternalTokenManagement) constructor path. That
constant is below CMT's UpsertMultiple batch-mode version gate
(9.2.23083.00120), so CMT silently fell back to slow, one-by-one
Create/Update calls through our shim regardless of how modern the real
connected org actually is.

Confirmed live against a current Dataverse online environment (real version
9.2.26061.150, SDK 1.2.10):
- ConnectedOrgVersion initially reports the SDK's stub default 9.0.0.0.
- ServiceClient.OrganizationDetail (public property, forces a real
  RefreshInstanceDetails) correctly returns the real version.
- Execute(new RetrieveVersionRequest()) also correctly returns the real
  version, as a further fallback.

Replaced the hardcoded constant with a cascade using only public SDK APIs:
base property -> OrganizationDetail -> RetrieveVersionRequest, falling back
to the honest SDK default only if every mechanism fails.

Filed upstream: microsoft/PowerPlatform-DataverseServiceClient#538

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants