Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update-MgBetaApplication failing with ErrorCode: DuplicateValueInDifferentCase #2549

Closed
cameron-doherty opened this issue Jan 30, 2024 · 2 comments
Assignees

Comments

@cameron-doherty
Copy link

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
Copy link
Author

cameron-doherty commented Feb 7, 2024

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?

@timayabi2020
Copy link
Contributor

Hi @cameron-doherty apologies for super late response on this issue. As for the case sensitivity I agree that it should not matter, unfortunately I don't have complete visibility on the service issue. I therefore advise that you first upgrade to the latest SDK (2.25.0) then raise an issue here https://developer.microsoft.com/en-us/graph/support so that the API owner can respond to it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants