fix: ConnectedOrgVersion returns 9.0.0.0 with token-provider auth#17
Merged
fix: ConnectedOrgVersion returns 9.0.0.0 with token-provider auth#17
Conversation
The Dataverse ServiceClient hardcodes OrganizationVersion to 9.0.0.0 in the ExternalTokenManagement (token-provider) constructor path — GetServerVersion and RefreshInstanceDetails are commented out in the SDK source. This causes Package Deployer to reject solutions requiring CDS >= 9.1. The existing shim's Execute(RetrieveVersion) fallback works in the common case, but if that call fails there was no further recovery. Add a second fallback that accesses ServiceClient.OrganizationDetail, which triggers the SDK's lazy RefreshInstanceDetails call and populates OrganizationVersion. Also move the org-version log line outside the Verbose guard in PackageDeployerRunner so it always appears in output and pre-warms the cache before Package Deployer reads it. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes incorrect Dataverse organization version reporting (9.0.0.0) when using the ServiceClient token-provider (ExternalTokenManagement) constructor path, which can cause Package Deployer to reject solutions requiring CDS >= 9.1.
Changes:
- Enhance the
CrmServiceClient.ConnectedOrgVersionshim to add a second fallback: trigger SDK lazy-loading viaOrganizationDetailwhenRetrieveVersionfails. - Always log the organization version in
PackageDeployerRunnerto pre-warm the version cache and improve diagnostics.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/TALXIS.CLI.Platform.XrmShim/CrmServiceClient.cs | Adds a second fallback to populate the real org version when the SDK returns a hardcoded default in token-provider auth. |
| src/TALXIS.CLI.Platform.Xrm/PackageDeployerRunner.cs | Logs org version unconditionally to ensure the shim is exercised before Package Deployer validation. |
Comments suppressed due to low confidence (1)
src/TALXIS.CLI.Platform.XrmShim/CrmServiceClient.cs:224
ConnectedOrgVersioncachesbaseVersioneven when it is the known-stale default (<= 9.0.0.0). IfRetrieveVersion/OrganizationDetailfails transiently, this permanently caches 9.0.0.0 for the process and prevents later retries, reintroducing the original failure mode. Consider only caching when a real version (> 9.0.0.0) is obtained, or using a short-lived/"unknown" sentinel so subsequent calls can retry.
var refreshedVersion = base.ConnectedOrgVersion;
if (refreshedVersion > new Version(9, 0, 0, 0))
{
_cachedOrgVersion = refreshedVersion;
return refreshedVersion;
}
}
catch
{
// OrganizationDetail may throw if the service is unreachable.
}
_cachedOrgVersion = baseVersion;
return baseVersion;
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Supersedes #13 with a corrected approach.
Problem
The Dataverse
ServiceClienthardcodesOrganizationVersion = 9.0.0.0in theExternalTokenManagement(token-provider) constructor path —GetServerVersionandRefreshInstanceDetailsare commented out in the SDK source. This causes Package Deployer to reject solutions requiring CDS ≥ 9.1 because it readsCrmSvc.ConnectedOrgVersionduring solution validation and sees the default9.0.0.0.Why PR #13's approach is incorrect
PR #13 adds a post-warm re-read of
base.ConnectedOrgVersionafter theExecute(RetrieveVersion)call, claiming thatExecutepopulatesOrganizationVersionas a side-effect. This is wrong — the SDK source shows thatExecutedoes not update_connectionSvc.OrganizationVersion; it stays hardcoded at9.0.0.0regardless of Execute calls.Correct fix
The existing shim's
Execute(RetrieveVersion)fallback works in the common case (it gets the version from the response body). But if that call fails, there was no recovery path.This PR adds a second fallback that accesses
ServiceClient.OrganizationDetail, which triggers the SDK's lazyConnectedOrganizationDetailgetter →RefreshInstanceDetails()→RetrieveCurrentOrganization→ updatesOrganizationVersion. Thenbase.ConnectedOrgVersionreturns the real version.Also moves the org-version log line outside the
if (Verbose)guard inPackageDeployerRunnerfor better diagnostics.Closes #13