msgraph-sdk-powershell icon indicating copy to clipboard operation
msgraph-sdk-powershell copied to clipboard

Update-MgBetaApplication failing with ErrorCode: DuplicateValueInDifferentCase

Open cameron-doherty opened this issue 1 year ago • 1 comments

Describe the bug When attempting to update an Application's onPremisesPublishing settings using Update-MgBetaApplication as instructed in the docs (LINK) an error occurs. The only difference being that the external_url being used is a custom/verified domain in Entra ID.

Line |
  54 |      Update-MgBetaApplication -ApplicationId $app_id -BodyParameter $n …
     |      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Request contains a property with duplicate values.  Status: 400 (BadRequest) ErrorCode: DuplicateValueInDifferentCase

However there is no indication of what duplicate value is causing the error. The documentation is being followed precisely yet the error still occurs.

To Reproduce Steps to reproduce the behavior:

  1. Create a new application with Invoke-MgInstantiateApplicationTemplate
  2. Useing Update-MgApplication, update the newly created application values as instructed...
$uri_params = @{
		identifierUris = @(
			$external_url
		)
		web = @{
			redirectUris = @(
				$external_url
			)
			homePageUrl = $external_url
		}
	}

where $external_url will be something along the lines of https://$application_name.myCustomDomain.com. The custom domain being used in place of msappproxy.net is a registered/verified domain in Entra ID.

  1. Update the onPremisesPublishing values for the application with Update-MgBetaApplication where -BodyParamater contains the following:
$new_params = @{
		onPremisesPublishing = @{
			externalAuthenticationType = "aadPreAuthentication"
			internalUrl = $internal_url
			externalUrl = $external_url
			isHttpOnlyCookieEnabled = $true
			isOnPremPublishingEnabled = $true
			isPersistentCookieEnabled = $true
			isSecureCookieEnabled = $true
			isStateSessionEnabled = $true
			isTranslateHostHeaderEnabled = $true
			isTranslateLinksInBodyEnabled = $true
		}
	}
  1. At this point an error occurs consistently stating Request contains a property with duplicate values. Status: 400 (BadRequest) ErrorCode: DuplicateValueInDifferentCase

Expected behavior After running Update-MgBetaApplication the expected response is HTTP/1.1 204 No content as per the docs.

Debug Output

DEBUG: ============================ HTTP REQUEST ============================

HTTP Method:
PATCH

Absolute Uri:
https://graph.microsoft.com/beta/applications/<redacted>

Headers:
FeatureFlag                   : 00000043
Cache-Control                 : no-store, no-cache
User-Agent                    : Mozilla/5.0,(Linux; Ubuntu 22.04.3 LTS; en-US),PowerShell/7.4.1
Accept-Encoding               : gzip
SdkVersion                    : graph-powershell-beta/2.12.0
client-request-id             : <redacted>

Body:
{
  "onPremisesPublishing": {
    "externalAuthenticationType": "aadPreAuthentication",
    "externalUrl": "<redacted>",
    "internalUrl": "<redacted>",
    "isHttpOnlyCookieEnabled": true,
    "isOnPremPublishingEnabled": true,
    "isPersistentCookieEnabled": true,
    "isSecureCookieEnabled": true,
    "isStateSessionEnabled": true,
    "isTranslateHostHeaderEnabled": true,
    "isTranslateLinksInBodyEnabled": true
  }
}


DEBUG: ============================ HTTP RESPONSE ============================

Status Code:
BadRequest

Headers:
Cache-Control                 : no-cache
Transfer-Encoding             : chunked
Vary                          : Accept-Encoding
Strict-Transport-Security     : max-age=31536000
request-id                    : <redacted>
client-request-id             : <redacted>
x-ms-ags-diagnostic           : {"ServerInfo":{"DataCenter":"West US","Slice":"E","Ring":"4","ScaleUnit":"003","RoleInstance":"SJ1PEPF00001C46"}}
Link                          : <https://developer.microsoft-tst.com/en-us/graph/changes?$filterby=beta,PrivatePreview:AppAutoTokenEncryption&from=2023-08-01&to=2023-09-01>;rel="deprecation";type="text/html",<https://developer.microsoft-tst.com/en-us/graph/changes?$filterby=beta,PrivatePreview:AppAutoTokenEncryption&from=2023-08-01&to=2023-09-01>;rel="deprecation";type="text/html",<https://developer.microsoft-tst.com/en-us/graph/changes?$filterby=beta,PrivatePreview:AppAutoTokenEncryption&from=2023-08-01&to=2023-09-01>;rel="deprecation";type="text/html",<https://developer.microsoft-tst.com/en-us/graph/changes?$filterby=beta,PrivatePreview:AppAutoTokenEncryption&from=2023-08-01&to=2023-09-01>;rel="deprecation";type="text/html",<https://developer.microsoft-tst.com/en-us/graph/changes?$filterby=beta,PrivatePreview:billingInformation&from=2022-09-01&to=2022-10-01>;rel="deprecation";type="text/html",<https://developer.microsoft-tst.com/en-us/graph/changes?$filterby=beta,PrivatePreview:billingInformation&from=2022-09-01&to=2022-10-01>;rel="deprecation";type="text/html",<https://developer.microsoft-tst.com/en-us/graph/changes?$filterby=beta,PrivatePreview:ApplicationsInAdministrativeUnits&from=2021-05-01&to=2021-06-01>;rel="deprecation";type="text/html",<https://developer.microsoft-tst.com/en-us/graph/changes?$filterby=beta,PrivatePreview:AppMigration&from=2023-07-01&to=2023-08-01>;rel="deprecation";type="text/html",<https://developer.microsoft-tst.com/en-us/graph/changes?$filterby=beta,PrivatePreview:AppMigration&from=2023-07-01&to=2023-08-01>;rel="deprecation";type="text/html",<https://developer.microsoft-tst.com/en-us/graph/changes?$filterby=beta,PrivatePreview:AppMigration&from=2023-07-01&to=2023-08-01>;rel="deprecation";type="text/html",<https://developer.microsoft-tst.com/en-us/graph/changes?$filterby=beta,PrivatePreview:AppMigration&from=2023-07-01&to=2023-08-01>;rel="deprecation";type="text/html"
Deprecation                   : Mon, 18 Apr 2022 23:59:59 GMT
Sunset                        : Thu, 18 Apr 2024 23:59:59 GMT
Date                          : Tue, 30 Jan 2024 18:51:57 GM

Body:
{
  "error": {
    "code": "DuplicateValueInDifferentCase",
    "message": "Request contains a property with duplicate values.",
    "innerError": {
      "date": "2024-01-30T18:51:58",
      "request-id": "<redacted>",
      "client-request-id": "<redacted>"
    }
  }
}

Module Version

ModuleType Version    PreRelease Name                                ExportedCommands
---------- -------    ---------- ----                                ----------------
Script     2.12.0                Microsoft.Graph.Beta.Applications   {Add-MgBetaApplicationKey, Add-MgBetaApplicationPassword, Add-MgBetaServicePrincipalTokenSigningCertificate, Clear-MgBetaApplicationVerifiedPublisher…}

Environment Data

Name                           Value
----                           -----
PSVersion                      7.4.1
PSEdition                      Core
GitCommitId                    7.4.1
OS                             Ubuntu 22.04.3 LTS
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

cameron-doherty avatar Jan 30 '24 18:01 cameron-doherty

Update as I've been playing more with this and it appears that I can bypass the error by explicitly setting variables toLower() such as in the following example:

BEFORE

$new_params = @{
		onPremisesPublishing = @{
			externalAuthenticationType = "aadPreAuthentication"
			internalUrl = $internal_url
			externalUrl = $external_url
			isHttpOnlyCookieEnabled = $true
			isOnPremPublishingEnabled = $true
			isPersistentCookieEnabled = $true
			isSecureCookieEnabled = $true
			isStateSessionEnabled = $true
			isTranslateHostHeaderEnabled = $true
			isTranslateLinksInBodyEnabled = $true
		}
	}

AFTER

$new_params = @{
		onPremisesPublishing = @{
			externalAuthenticationType = "aadPreAuthentication"
			internalUrl = $internal_url.toLower() #<--- ADDED
			externalUrl = $external_url.toLower() #<--- ADDED
			isHttpOnlyCookieEnabled = $true
			isOnPremPublishingEnabled = $true
			isPersistentCookieEnabled = $true
			isSecureCookieEnabled = $true
			isStateSessionEnabled = $true
			isTranslateHostHeaderEnabled = $true
			isTranslateLinksInBodyEnabled = $true
		}
	}

No more DuplicateValueInDifferentCase error and process is able to complete successfully.

This begs the question why would the case matter? Is there some scenario where values passed via the cmdlets are definitely case sensitive?

cameron-doherty avatar Feb 07 '24 00:02 cameron-doherty