-
Notifications
You must be signed in to change notification settings - Fork 86
Description
Describe the bug
MultiSelectPicklistType generated as single value instead of collection in Code Apps model generation
Steps to Reproduce
When using Power Apps Code Apps with Dataverse MultiSelect Picklist field is incorrectly generated as a single enum value instead of a collection (number[]).
This causes runtime OData errors when submitting valid array values.
Expected behavior
For a Dataverse MultiSelectPicklistType, the generated model should be something like:
qbstk_safecontactmethods?: number[];
Or a strongly-typed equivalent such as:
qbstk_safecontactmethods?: Qbstk_housinghomesecuritydfvcloseoutformsqbstk_safecontactmethods[];
Additionally, the JSON schema should reflect:
"type": "array",
"items": {
"type": "integer"
}
Actual behavior
Error
Screenshots or Error Messages
"message":"{"error":{"code":"0x80048d19","message":"Error identified in Payload provided by the user for Entity :'qbstk_housinghomesecuritydfvcloseoutforms', For more information on this error please follow this help link https://go.microsoft.com/fwlink/?linkid=2195293 ----> InnerException : Microsoft.OData.ODataException: An unexpected 'StartArray' node was found when reading from the JSON reader. A 'PrimitiveValue' node was expected.\r\n at Microsoft.OData.Json.JsonReaderExtensions.ValidateNodeType(IJsonReader jsonReader, JsonNodeType expectedNodeType)\r\n at Microsoft.OData.JsonLight.ODataJsonLightPropertyAndValueDeserializer.ReadPrimitiveValue(Boolean insideJsonObjectValue, IEdmPrimitiveTypeReference expectedValueTypeReference, Boolean validateNullValue, String propertyName)\r\n at Microsoft.OData.JsonLight.ODataJsonLightPropertyAndValueDeserializer.ReadNonEntityValueImplementation(String payloadTypeName, IEdmTypeReference expectedTypeReference, PropertyAndAnnotationCollector propertyAndAnnotationCollector, CollectionWithoutExpectedTypeValidator collectionValidator, Boolean validateNullValue, Boolean isTopLevelPropertyValue, Boolean insideResourceValue, String propertyName, Nullable1 isDynamicProperty)\\r\\n at Microsoft.OData.JsonLight.ODataJsonLightResourceDeserializer.ReadEntryDataProperty(IODataJsonLightReaderResourceState resourceState, IEdmProperty edmProperty, String propertyTypeName)\\r\\n at Microsoft.OData.JsonLight.ODataJsonLightResourceDeserializer.ReadPropertyWithValue(IODataJsonLightReaderResourceState resourceState, String propertyName, Boolean isDeltaResourceSet)\\r\\n at Microsoft.OData.JsonLight.ODataJsonLightResourceDeserializer.<>c__DisplayClass9_0.<ReadResourceContent>b__0(PropertyParsingResult propertyParsingResult, String propertyName)\\r\\n at Microsoft.OData.JsonLight.ODataJsonLightDeserializer.ProcessProperty(PropertyAndAnnotationCollector propertyAndAnnotationCollector, Func2 readPropertyAnnotationValue, Action2 handleProperty)\\r\\n at Microsoft.OData.JsonLight.ODataJsonLightResourceDeserializer.ReadResourceContent(IODataJsonLightReaderResourceState resourceState)\\r\\n at Microsoft.OData.JsonLight.ODataJsonLightReader.ReadNextNestedInfo()\\r\\n at Microsoft.OData.JsonLight.ODataJsonLightReader.ReadAtNestedResourceInfoEndImplementation()\\r\\n at Microsoft.OData.ODataReaderCore.ReadImplementation()\\r\\n at Microsoft.OData.ODataReaderCore.InterceptException[T](Func1 action)\r\n at Microsoft.AspNet.OData.Formatter.Deserialization.ODataReaderExtensions.ReadResourceOrResourceSet(ODataReader reader)\r\n at Microsoft.Crm.Extensibility.CrmODataEntityDeserializer.Read(ODataMessageReader messageReader, Type type, ODataDeserializerContext readContext)\r\n at Microsoft.AspNet.OData.Formatter.ODataInputFormatterHelper.ReadFromStream(Type type, Object defaultValue, IEdmModel model, ODataVersion version, Uri baseAddress, IWebApiRequestMessage internalRequest, Func1 getODataRequestMessage, Func2 getEdmTypeDeserializer, Func2 getODataPayloadDeserializer, Func1 getODataDeserializerContext, Action1 registerForDisposeAction, Action1 logErrorAction)."}}","status":400,"requestId":"71930933-936c-42bf-959c-fe6895360cff"}
Environment information
- Framework, build tool or relevant package used: [React,Vite, Webpack, etc]
- Any connection/components: [Office365, SQL, etc]
Additional context
Power Apps Code Apps
Dataverse backend
pac CLI (latest as of report)
Generator output under:
.power/schemas/appschemas/
src/generated/models/
Dataverse Metadata (Correct)
From Web API metadata:
{
"@odata.type": "#Microsoft.Dynamics.CRM.MultiSelectPicklistAttributeMetadata",
"AttributeType": "Virtual",
"LogicalName": "qbstk_safecontactmethods",
"AttributeTypeName": {
"Value": "MultiSelectPicklistType"
}
}
Generated Schema (Incorrect)
From homesecurityclosouts.Schema.json:
"qbstk_safecontactmethods": {
"type": "string",
"title": "Safe Contact Methods",
"x-ms-dataverse-attribute": "qbstk_safecontactmethods",
"x-ms-dataverse-type": "MultiSelectPicklistType",
"enum": [
"Phone",
"SMS",
"Email"
],
"x-ms-enum-values": [
938490000,
938490001,
938490002
]
}
"type": "string" is incorrect for a MultiSelectPicklistType.
Generated TypeScript Model (Incorrect)
qbstk_safecontactmethods?: Qbstk_housinghomesecuritydfvcloseoutformsqbstk_safecontactmethods;
export const Qbstk_housinghomesecuritydfvcloseoutformsqbstk_safecontactmethods = {
938490000: 'Phone',
938490001: 'SMS',
938490002: 'Email'
} as const;
export type Qbstk_housinghomesecuritydfvcloseoutformsqbstk_safecontactmethods =
keyof typeof Qbstk_housinghomesecuritydfvcloseoutformsqbstk_safecontactmethods;
This represents the field as a single enum value, not a collection.
Actual Runtime Impact
When submitting valid multi-select data:
qbstk_safecontactmethods: [938490000, 938490001]
Dataverse throws:
Microsoft.OData.ODataException:
An unexpected 'StartArray' node was found when reading from the JSON reader.
A 'PrimitiveValue' node was expected.
This occurs because:
The generated model expects a primitive.
The server expects a collection.
Root Cause
The schema generator is mapping:
x-ms-dataverse-type: MultiSelectPicklistType
to:
"type": "string"
instead of an array type.
This appears to be a generation defect specific to Code Apps schema generation.