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

[Bug] "--area is not present in current organization" error during "az devops invoke --area Security" execution #1011

Open
DariuszPorowski opened this issue Jun 4, 2020 · 13 comments
Assignees
Labels
Area: ProToCol The bugs under ProToCol Team bug

Comments

@DariuszPorowski
Copy link

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Azure Cli Version: 2.70
Azure-Devops extension version: 0.18.0

Steps to reproduce the behavior:
run:
az devops invoke --organization "https://dev.azure.com/myorg" --area "Security" --resource "SecurityNamespaces"
and see error:
--area is not present in current organization

Expected behavior
Results the same as using GET rest call:
https://dev.azure.com/myorg/_apis/securitynamespaces?api-version=5.1

Debug logs
cli.azure.cli.core.util : --area is not present in current organization
--area is not present in current organization

Additional context
Add any other context about the problem here.

@DariuszPorowski DariuszPorowski added Area: ProToCol The bugs under ProToCol Team bug labels Jun 4, 2020
@DariuszPorowski DariuszPorowski changed the title [Bug] [Bug] "--area is not present in current organization" error during "az devops invoke --area Security" execution Jun 4, 2020
@ashishonce ashishonce assigned ashishonce and unassigned ashishonce Jun 9, 2020
@jdholbrook81
Copy link

Also getting this trying to register a web hook:

az devops invoke --organization $organization --http-method POST --area hooks --resource subscriptions --in-file $webhookJsonPath

Result: --area is not present in current organization

@tasb
Copy link

tasb commented Sep 4, 2020

I'm having the same issue too. Any update on this?

@ashishonce
Copy link
Member

ashishonce commented Sep 6, 2020

I see that command
az devops invoke --organization "https://dev.azure.com/" --area "Security" --resource "SecurityNamespaces"

has two step process

first step :
is invoking below API
https://dev.azure.com/yourorg/_apis/ResourceAreas
to get list of all resource areas, and only when provided area is found in the list

it proceeds with particular url for resource within that area. That will be like
https://dev.azure.com/yourorg/_apis/securitynamespaces?api-version=5.1

I see that for the first request area name "Security" is not present and thus the logic fails citing that "Security" is not present in available areas.

I am not sure why this API https://dev.azure.com/yourorg/_apis/ResourceAreas will not return full list of Areas which is provided by
az devops invoke --organization "https://dev.azure.com/yourorg"

you can verify this my running below command to check that when all areas are scanned separately, we do get "Security" as available area.

az devops invoke --organization "https://dev.azure.com/yourorg" --query "[?contains(area,'Security')]"

@narula0781 can we connect with API team for this bug?
I will connect with the API team to know more around this.

@rhatfield-bushel
Copy link

rhatfield-bushel commented Sep 8, 2021

So I ran into this issue, and "fixed" it locally, but could use some guidance on how to properly implement the fix in this repo.

So first, I don't code in python very often so I probably shouldn't be writing the fix.

There's two bugs here causing this behavior:

  • not accounting for resource version in version string
    • Currently this fails when trying to parse a float
    • This one seems like an easy fix but I don't really want to look up how to do it in python
    • the trailing .1 from 6.0-preview.1 needs to be accounted for. It's still being passed correctly to the end web request, but the float bug doesn't let us call the correct version of the API
  • not correctly resolving the base url
    • the way the area is found here is very basic. I would suggest defaulting to the core URL, as that's the correct URL from the documentation for me.
    • I updated the code as follows to work for me, though I'm sure there's much better ways to write this:
if not client_url:
    for resource_area in resource_areas:
        if resource_area.name.lower() == 'core':
            client_url = resource_area.location_url

So, all the parts to fix this should be here. With a little guidance on this I could make a PR with a VERY basic fix, but I won't have the time to contribute any tests for this.

With the above fixes in place, I'm able to call this with the correct API resource and area:

az devops invoke \
  --organization "https://dev.azure.com/yourorg" \
  --area "Security" \
  --resource "SecurityNamespaces" \
  --api-version 6.1.1

I got the appropriate endpoint version from the az devops invoke details:

{
    "area": "Security",
    "id": "ce7b9f95-fde9-4be8-a86d-83b366f0b87a",
    "maxVersion": 6.1,
    "minVersion": 1.0,
    "releasedVersion": "6.0",
    "resourceName": "SecurityNamespaces",
    "resourceVersion": 1,
    "routeTemplate": "_apis/{resource}/{securityNamespaceId}"
}

@gauravsaralMs gauravsaralMs added this to Backlog in Azure DevOps CLI Extension via automation Oct 14, 2021
@gauravsaralMs gauravsaralMs moved this from Backlog to Planned in Azure DevOps CLI Extension Oct 14, 2021
@tobylo
Copy link

tobylo commented Feb 3, 2022

Any update on this? Also getting the same error when trying to invoke the securityroles area (to update/set permissions on an environment).

@stevenoneill
Copy link

Getting this error when trying to use --area Contribution. Any update?

@kvakulo
Copy link

kvakulo commented Jun 28, 2022

Also hit by this error for --scope securityroles 😞

@silverscout
Copy link

silverscout commented Sep 6, 2022

@rhatfield-bushel this like I am getting this error on --area processes. I did your fix of updating the invoke.py file and it resolved the issue. Hopefully one day this will get merged in.

@SaurabhSharma-MSFT
Copy link
Member

@gauravsaralMs Can you please look into this.

@dimangulov
Copy link

Also hit by this error for --scope securityroles

@micwiec
Copy link

micwiec commented Oct 13, 2023

Issue still exists

@lukecalderon
Copy link

Currently having the same issue with the following:

Command

az devops invoke --area "securityRoles" --resource "roleassignments" `
  --route-parameters scopeId="distributedtask.agentpoolrole" resource="$adoAgentPoolId" `
  --detect true `
  --http-method PUT `
  --api-version "7.2-preview" `
  --in-file agentPoolBody.json `
  -o json

Response

ERROR: --area is not present in current organization

sskoklev added a commit to sskoklev/azure-devops-cli-extension that referenced this issue Feb 29, 2024
sskoklev: Fix as suggested in Azure#1011 (comment).
@Albert0sans
Copy link

any updates?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: ProToCol The bugs under ProToCol Team bug
Projects
Development

No branches or pull requests