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

Dangling name error when trying to update extensionAttributes on a device #2166

Open
iantmc87 opened this issue Sep 23, 2024 · 1 comment
Open
Assignees
Labels
area:serialization Focused on functional modules of the product type:bug A broken experience

Comments

@iantmc87
Copy link

iantmc87 commented Sep 23, 2024

Describe the bug

I am trying to update one of the extensionAttribute values within the additionalData of a device, but getting the following error:

java.lang.IllegalStateException: Dangling name: extensionAttributes

I'm following the example 2 from here - https://learn.microsoft.com/en-us/graph/api/device-update?view=graph-rest-1.0&tabs=java - although the example isn't fully complete for updating the extensionAttributes. There seems to be a model within the SDK to use for OnPremiseExtensionAttributes but not for extensionAttributes.

If I get additonalData using device.getAdditionalData() it contains the the list of the 15 extensionAttributes that can be used.

Expected behavior

Expect the extensionAttribute to update successfully, which works if updating via HTTP for example.

How to reproduce

Device newDevice = new Device();
		
Map<String,Object> additionalData = new HashMap<>();

Map<String,String> attribute = new HashMap<>();
attribute.put("extensionAttribute1", "123456");

additionalData.put("extensionAttributes", attribute);

newDevice.setAdditionalData(additionalData);

try {
	client.devices().byDeviceId(deviceId).patch(newDevice);
} catch(Exception e) {
	//handle exception
}

SDK Version

6.16.0

Latest version known to work for scenario above?

No response

Known Workarounds

No response

Debug output

Click to expand log ```
</details>


### Configuration

_No response_

### Other information

_No response_
@iantmc87 iantmc87 added status:waiting-for-triage An issue that is yet to be reviewed or assigned type:bug A broken experience labels Sep 23, 2024
@Ndiritu Ndiritu added area:serialization Focused on functional modules of the product and removed status:waiting-for-triage An issue that is yet to be reviewed or assigned labels Sep 24, 2024
@andrueastman
Copy link
Member

Thanks for raising this @iantmc87

I believe the issue here is that the serializer does not handle maps when present in the addtionalData. To do this, we would need to add a case in this function to handle maps so that the seriliazer does not write the key and nothing is written for its value.

https://github.com/microsoft/kiota-java/blob/5d6671eee75d77e415248d40f1113cb63886fbdd/components/serialization/json/src/main/java/com/microsoft/kiota/serialization/JsonSerializationWriter.java#L494C54-L494C76

@Ndiritu Ndiritu self-assigned this Oct 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:serialization Focused on functional modules of the product type:bug A broken experience
Projects
None yet
Development

No branches or pull requests

3 participants