microsoft / microsoft/Dynamics365Commerce.Solutions
Retail Proxy (C#) entity creation error / serialization issue.
Nobody has claimed this yet.
- Dominant language
- No language data
- Stars
- 80
- Forks
- 38
- PR merge metrics
- No merged PRs in 30d
Description
Retail Proxy (C#) Issue during entity creation
Summary
Describe the issue
Attempting to create a customer through the retail proxy > RetailServerContext > CustomerManager.
When creating a customer, I get an error "(A null value was found for the property named 'AccountNumber', which has the expected type 'Edm.String[Nullable=False]'" - however I have left that property off when configuring the customer."
This property was not set when populating in the new customer object. I think the retail proxy/server context is serializing the whole customer object instead of just the properties that have been set or changed.
var manager = _managerFactory.GetManager<ICustomerManager>();
var customer = new Customer()
{
//only setting the properties I want created for the customer.
};
//this results in the error (seen in event viewer logs for the retail server)
customer = await manager.Create(customer);
If calling: customer.SerializeToJsonObject(); the serialization occurs correctly, however this serialization is ignored in the RetailServerContext and underlying data service context.
I assume this occurs with all the retail proxy create calls & not just customer.
Version and Error Info
Sample Version:
9.54.25212.2 - Microsoft.Dynamics.Commerce.Proxy.ScaleUnit
10.0.44 - Commerce Scale Unit (SEALED)
Microsoft.OData.ODataException: A null value was found for the property named 'AccountNumber', which has the expected type 'Edm.String[Nullable=False]'. The expected type 'Edm.String[Nullable=False]' does not allow null values.
at Microsoft.OData.ReaderValidationUtils.ThrowNullValueForNonNullableTypeException(IEdmTypeReference expectedValueTypeReference, String propertyName)
at Microsoft.OData.ReaderValidationUtils.ValidateNullValueAllowed(IEdmTypeReference expectedValueTypeReference, Boolean validateNullValue, String propertyName, Nullable`1 isDynamicProperty)
at Microsoft.OData.ReaderValidationUtils.ValidateNullValue(IEdmTypeReference expectedTypeReference, Boolean enablePrimitiveTypeConversion, Boolean validateNullValue, String propertyName, Nullable`1 isDynamicProperty)
at Microsoft.OData.ReaderValidator.ValidateNullValue(IEdmTypeReference expectedTypeReference, Boolean validateNullValue, String propertyName, Nullable`1 isDynamicProperty)
at Microsoft.OData.Json.ODataJsonReaderCoreUtils.TryReadNullValue(IJsonReader jsonReader, ODataInputContext inputContext, IEdmTypeReference expectedTypeReference, Boolean validateNullValue, String propertyName, Nullable`1 isDynamicProperty)
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the customer creation path through RetailServerContext and CustomerManager with the shown minimal Customer object, then compare it with SerializeToJsonObject(). Confirm whether the context sends unset AccountNumber as null; done means the create request omits unset properties and succeeds.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100