Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

[BUG] One or more fields contain incorrect values:","details":[{"code":"ValidationError","target":"name","message":"Tag with the same name already exists.

Open
#855 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
42/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
azure, csharp, powershell
Domain
api, ci-cd, cloud

Research direction

Start by reproducing the failure with the shown Azure DevOps pipeline and the publisher executable against an APIM instance containing an existing tag. Read the publisher's API Management tag handling and verify that synchronization updates or safely replaces duplicate tags; done means publishing the test artifacts to production succeeds without the duplicate-name validation error.

Written by the indexing model from the issue text.

Description

Release version

APIOps release version 6.0.2

Describe the bug

##[error]Unhandled exception. System.Net.Http.HttpRequestException: HTTP request to URI https://management.azure.com/subscriptions/***/resourceGroups/prd-int-it-rg-eaiapim/providers/Microsoft.ApiManagement/service/prd-eaiapimint-apim-01/tags/programs-673e0548c5f6294c3c3daf2f?api-version=2023-09-01-preview failed with status code 400. Content is '{"error":{"code":"ValidationError","message":"One or more fields contain incorrect values:","details":[{"code":"ValidationError","target":"name","message":"Tag with the same name already exists."}]}}'.

Expected behavior

I am trying to publish artifacts from test to prod. This APIM instance already exist and it should be fine and I should be able to overwrite the instance somehow.

Actual behavior

But it keeps failing with these errors that already exist, It should overwrite it without complaining. I am try to sync the changes from test to PROD.

Reproduction Steps

parameters:

  • name: API_MANAGEMENT_SERVICE_OUTPUT_FOLDER_PATH
    type: string
    displayName: Folder where the artifacts reside
  • name: ENVIRONMENT
    type: string
    displayName: Environment to display
  • name: RESOURCE_GROUP_NAME
    type: string
    displayName: Resource Group Name
  • name: API_MANAGEMENT_SERVICE_NAME
    type: string
    displayName: APIM Instance Name
    default: ""
  • name: CONFIGURATION_YAML_PATH
    type: string
    displayName: Optional configuration file
    default: ""
  • name: SUBSCRIPTION_ID
    type: string
    displayName: Azure Subscription ID
    default: ""
  • name: COMMIT_ID
    type: string
    default: publish-artifacts-in-last-commit

steps:

  • script: echo Provided configuration was ${{ parameters.CONFIGURATION_YAML_PATH }}
    displayName: Print the name of the yaml configuration file if provided

  • script: echo Provided app service name was ${{ parameters.API_MANAGEMENT_SERVICE_NAME }}
    displayName: Print the name of the apim service name if provided

  • checkout: self
    fetchDepth: 0

  • task: AzureCLI@2
    displayName: Set publishing variables
    inputs:
    azureSubscription: "$(SERVICE_CONNECTION_NAME)"
    scriptType: pscore
    scriptLocation: inlineScript
    inlineScript: |
    Set-StrictMode -Version Latest
    $ErrorActionPreference = "Stop"
    $VerbosePreference = "Continue"
    $InformationPreference = "Continue"

    Write-Host "##vso[task.setvariable issecret=true;variable=AZURE_BEARER_TOKEN]$(az account get-access-token --query "accessToken" --output tsv)"
    Write-Host "##vso[task.setvariable issecret=true;variable=AZURE_CLIENT_ID]$env:servicePrincipalId"
    Write-Host "##vso[task.setvariable issecret=true;variable=AZURE_CLIENT_SECRET]$env:servicePrincipalKey"
    Write-Host "##vso[task.setvariable issecret=true;variable=AZURE_TENANT_ID]$env:tenantId"
    $paramSubscriptionId = "${{ parameters.SUBSCRIPTION_ID }}"
    if ($paramSubscriptionId) {
      Write-Host "Using subscription ID from parameter: $paramSubscriptionId"
      Write-Host "##vso[task.setvariable issecret=true;variable=AZURE_SUBSCRIPTION_ID]$paramSubscriptionId"
    }
    elseif (-not $env:AZURE_SUBSCRIPTION_ID) {
      $subscriptionCount = az account list --query "length([])" --output tsv
      if ($subscriptionCount -eq 1) {
          $subscriptionId = az account list --query "[0].id" --output tsv
          Write-Host "Setting AZURE_SUBSCRIPTION_ID environment variable to: $subscriptionId"
          Write-Host "##vso[task.setvariable issecret=true;variable=AZURE_SUBSCRIPTION_ID]$($subscriptionId)"
      } 
      elseif ($subscriptionCount -gt 1) {
          Write-Host "Multiple subscriptions are accessible. Please set the AZURE_SUBSCRIPTION_ID environment variable manually."
          exit 1
      }
    }
    else {
      Write-Host "AZURE_SUBSCRIPTION_ID is already set to: $env:AZURE_SUBSCRIPTION_ID"
    }
    

    addSpnToEnvironment: true
    failOnStandardError: true

replacetokens@6 task will need to be installed to use

  • ${{ if ne(parameters.CONFIGURATION_YAML_PATH, '') }}:

    • task: qetza.replacetokens.replacetokens-task.replacetokens@6
      displayName: "Perform namevalue secret substitution in ${{ parameters.CONFIGURATION_YAML_PATH }}"
      inputs:
      sources: ${{ parameters.CONFIGURATION_YAML_PATH }}
      encoding: "auto"
      addBOM: true
      verbosity: "off"
      missingVarAction: "none"
      missingVarLog: "warn"
      tokenPattern: "custom"
      tokenPrefix: "{#"
      tokenSuffix: "#}"
  • task: PowerShell@2
    displayName: Fetch publisher
    inputs:
    targetType: "inline"
    script: |
    Set-StrictMode -Version Latest
    $ErrorActionPreference = "Stop"
    $VerbosePreference = "Continue"
    $InformationPreference = "Continue"

    Write-Information "Setting name variables..."
    $releaseFileName = "publisher-linux-x64.zip"
    $executableFileName = "publisher"
    
    if ("$(Agent.OS)" -like "*win*") {
      $releaseFileName = "publisher-win-x64.zip"
      $executableFileName = "publisher.exe"
    }
    elseif ("$(Agent.OS)" -like "*mac*" -and "$(Agent.OSArchitecture)" -like "*arm*") {
      $releaseFileName = "publisher-osx-arm64.zip"
    }
    elseif ("$(Agent.OS)" -like "*mac*" -and "$(Agent.OSArchitecture)" -like "*x86_64*") {
      $releaseFileName = "publisher-osx-x64.zip"
    }
    
    Write-Information "Downloading release..."
    $uri = "https://github.com/Azure/apiops/releases/download/$(apiops_release_version)/$releaseFileName"
    $downloadFilePath = Join-Path "$(Agent.TempDirectory)" $releaseFileName
    Invoke-WebRequest -Uri "$uri" -OutFile "$downloadFilePath"
    
    Write-Information "Extracting release..."
    $executableFolderPath = Join-Path "$(Agent.TempDirectory)" "publisher"
    Expand-Archive -Path "$downloadFilePath" -DestinationPath "$executableFolderPath"
    $executableFilePath = Join-Path "$executableFolderPath" $executableFileName
    
    Write-Information "Setting file permissions..."
    if ("$(Agent.OS)" -like "*linux*")
    {
      & chmod +x "$executableFilePath"
      if ($LASTEXITCODE -ne 0) { throw "Setting file permissions failed."}
    }
    
    Write-Host "##vso[task.setvariable variable=PUBLISHER_FILE_PATH]$executableFilePath"
    Write-Information "Execution complete."
    

    failOnStderr: true
    pwsh: true

  • task: PowerShell@2
    displayName: Run publisher for ${{ parameters.ENVIRONMENT}} environment
    inputs:
    targetType: "inline"
    script: |
    Set-StrictMode -Version Latest
    $ErrorActionPreference = "Stop"
    $VerbosePreference = "Continue"
    $InformationPreference = "Continue"

    & "$(PUBLISHER_FILE_PATH)"                
    if ($LASTEXITCODE -ne 0) { throw "Running publisher failed."}
    
    Write-Information "Execution complete."
    

    failOnStderr: true
    pwsh: true
    env:
    AZURE_BEARER_TOKEN: $(AZURE_BEARER_TOKEN)
    AZURE_CLIENT_ID: $(AZURE_CLIENT_ID)
    AZURE_CLIENT_SECRET: $(AZURE_CLIENT_SECRET)
    AZURE_TENANT_ID: $(AZURE_TENANT_ID)
    AZURE_SUBSCRIPTION_ID: $(AZURE_SUBSCRIPTION_ID)
    AZURE_RESOURCE_GROUP_NAME: ${{ parameters.RESOURCE_GROUP_NAME }}
    API_MANAGEMENT_SERVICE_OUTPUT_FOLDER_PATH: $(Build.SourcesDirectory)/${{ parameters.API_MANAGEMENT_SERVICE_OUTPUT_FOLDER_PATH }}
    ${{ if ne( parameters['API_MANAGEMENT_SERVICE_NAME'], '' ) }}:
    API_MANAGEMENT_SERVICE_NAME: ${{ parameters.API_MANAGEMENT_SERVICE_NAME }}
    ${{ if eq( parameters['COMMIT_ID'], 'publish-artifacts-in-last-commit' ) }}:
    COMMIT_ID: $(Build.SourceVersion)
    ${{ if ne( parameters['CONFIGURATION_YAML_PATH'], '' ) }}:
    CONFIGURATION_YAML_PATH: ${{ parameters.CONFIGURATION_YAML_PATH }}

Dominant language
C#
Stars
448
Forks
247
PR merge metrics
No merged PRs in 30d

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.

More from Azure/apiops

All issues in Azure/apiops

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.