Skip to content

Duplicate values in enum extensions are not diagnosed until publish, with weird error if used #6678

@dzzzb

Description

@dzzzb

Given this code:

enumextension 50100 Test extends "Workflow Approver Type"
{
    value(51045; Test)
    {
        Caption = 'Test';
    }

    value(51045; Test)
    {
        Caption = 'Test';
    }
}

No diagnostic is emitted in the PROBLEMS tab, despite the obvious duplicate value!

Only upon publishing are we told the following:

The request for path /BC/dev/apps?tenant=default&SchemaUpdateMode=synchronize&DependencyPublishingOption=default failed with code UnprocessableEntity. Reason: An error occurred while applying changes from the object of type 'EnumExtension' with ID '50100' in the 'ALProject1 by Default publisher 1.0.0.0' app to the application object of type 'Enum' with the ID '460'. Failing delta: Type: EnumValueAddDelta; TargetKind: Other; OrdinalValue: 51045 The error was: InvalidOperationException - Metadata delta application failed due to the following error(s): The enum 'Workflow Approver Type' already has a value with the ordinal value: '51045'.; The enum 'Workflow Approver Type' already has a value with the name: 'Test'.


If we then use said value(s)... we instead (not also) get a much more confusing error - which (assuming then enumextension is in another file, far away, forgotten about, etc.) leaves us chasing red herrings until we reduce down the code and find that we had simply duped a value.

codeunit 50100 Test
{
    trigger OnRun()
    var
        WorkflowApproverType: Enum "Workflow Approver Type";
    begin
        if WorkflowApproverType = WorkflowApproverType::Test then
            ;
    end;
}

...which gives...

The request for path /BC/dev/apps?tenant=default&SchemaUpdateMode=synchronize&DependencyPublishingOption=default failed with code UnprocessableEntity. Reason: One or more errors occurred.
Failure while emitting method. Object:'Codeunit Test' Method:'ApprovalsMgmtOnCreateApprovalRequestsOnElseCase(Record "Workflow Step Argument", var Record "Approval Entry")'
Unexpected value 'NoConversion' of type 'Microsoft.Dynamics.Nav.CodeAnalysis.ConversionKind'


Please revise so an error is given in the PROBLEMS tab, stopping the build before deployment with a clear explanation of the problem, rather than not erroring during compilation and then potentially confusing devs a lot during release (as per scenario 2).


Name: AL Language
Id: ms-dynamics-smb.al
Description: AL development tools for Dynamics 365 Business Central
Version: 7.2.475273
Publisher: Microsoft
VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=ms-dynamics-smb.al

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugProduct bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions