microsoftgraph / microsoftgraph/msgraph-sdk-python

Patch application to add new app_role throws ODataError `Request contains a property with duplicate values.`

Open
#233 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Needs: Attention :wave:
Dominant language
Python
Stars
630
Forks
96
Avg merge
15h 20m
Merged PRs (30d)
3

Description

Hello,

I would like to add a new app_role called test to an app registration, I used following code, but got ODataError Request contains a property with duplicate values.:

from msgraph.generated.models.application import Application
from msgraph.generated.models.app_role import AppRole
from uuid import uuid4
# some other imports and client init ignored here, as not relevant

app_id = "an existing app id"
role_name = "test"
app_role = AppRole()
app_role.allowed_member_types = ["User", "Application"]
app_role.description = role_name
app_role.display_name = role_name
app_role.is_enabled = True
app_role.id = str(uuid4())
app_role.origin = "Application"
app_role.value = role_name
app = Application()
app.app_roles = [app_role]
# get() is OK
get_result = await client.applications.by_application_id(app_id).get()
# patch is KO
patch_result = await client.applications.by_application_id(app_id).patch(body=app)

The below command throws error: 'Request contains a property with duplicate values.' (code: DuplicateValue) after the internal command:
https://github.com/microsoftgraph/msgraph-sdk-python/blob/33cb15a452bd92b85ae62faaecc879761586237f/msgraph/generated/applications/item/application_item_request_builder.py#L123

Could you please give a help to explain what are the duplicate values, I checked the model of app_role, it should be OK:
https://github.com/microsoftgraph/msgraph-sdk-python/blob/main/msgraph/generated/models/app_role.py

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the PATCH call in msgraph/generated/applications/item/application_item_request_builder.py around line 123 and inspect the AppRole model in msgraph/generated/models/app_role.py. Reproduce the request using the supplied example and determine which values the Microsoft Graph API treats as duplicates. Done means the cause and required PATCH behavior are clearly established, with a regression test or documentation update if the repository supports one.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.