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

queryById, getQuery, getQueries only search queries in "My Queries" and not "Shared Queries" #586

Open
MartinPriebe opened this issue Feb 29, 2024 · 3 comments

Comments

@MartinPriebe
Copy link

MartinPriebe commented Feb 29, 2024

Environment

Node version: v20.11.1
Npm version: 10.4.0
OS and version: Windows 11
azure-devops-node-api version: 12.4.0

Issue Description

The api calls queryById and getQuery return null. I think they are searching in "My Queries" and not in "Shared Queries".
getQueries api Call return the folder "My Queries" without content.

Expected behaviour

SYSTEMVSSCONNECTION can access "SharedQueries".

Actual behaviour

queryById returns null (because query is stored in SharedQueries)
getQuery returns null (because query is stored in SharedQueries)
getQueries return just My Queries folder but also without content.

Steps to reproduce

Create an extension and call this function.

function getOrgUrl() : string
{
    return tl.getEndpointUrl('SYSTEMVSSCONNECTION', false)!;     
}

function getADOConnection() : azdev.WebApi
{
    const token = tl.getEndpointAuthorizationParameter('SYSTEMVSSCONNECTION', 'AccessToken', false)!;
    const orgUrl = getOrgUrl();
            
    const authHandler = azdev.getBearerHandler(token)!;
    return new azdev.WebApi(orgUrl, authHandler);
}

async function getWiqlByQueryId(connection: azdev.WebApi, project: string, id: string) : Promise<string> {
    const wit: witapi.IWorkItemTrackingApi = await connection.getWorkItemTrackingApi();

    tl.debug("getWiqlByQueryId project: " + project); //correct project ID
    tl.debug("getWiqlByQueryId id: " + id); //correct Query ID

    const resultQ = await wit.queryById(id);
    tl.debug("getWiqlByQueryId result: " + JSON.stringify(resultQ)); //return null

    const queries: witif.QueryHierarchyItem[] = await wit.getQueries(project, witif.QueryExpand.Wiql, 2);
    tl.debug("getWiqlByQueryId result: " + JSON.stringify(queries)); //return json with My Queries folder only, no queries

    const result = await wit.getQuery(project, id, witif.QueryExpand.Wiql, 2);
    tl.debug("getWiqlByQueryId result: " + JSON.stringify(result));   //return null

    return await getWiqlById(result, id);
}

Logs

##[debug]loading inputs and endpoints
##[debug]loading INPUT_PROJECT
##[debug]loading INPUT_QUERY
##[debug]loading INPUT_SUBJECT
##[debug]loading INPUT_EMAILADDRESSES
##[debug]loading ENDPOINT_AUTH_SYSTEMVSSCONNECTION
##[debug]loading ENDPOINT_AUTH_SCHEME_SYSTEMVSSCONNECTION
##[debug]loading ENDPOINT_AUTH_PARAMETER_SYSTEMVSSCONNECTION_ACCESSTOKEN
##[debug]loading SECRET_SYSTEM_ACCESSTOKEN
##[debug]loaded 8
##[debug]Agent.ProxyUrl=undefined
##[debug]Agent.CAInfo=undefined
##[debug]Agent.ClientCert=undefined
##[debug]Agent.SkipCertValidation=undefined
##[debug]Starting process..
##[debug]SYSTEMVSSCONNECTION=https://dev.azure.com/*myOrg*/
##[debug]project=908****************************
##[debug]query=9e7******************************
##[debug]SYSTEMVSSCONNECTION auth param AccessToken = ***
##[debug]SYSTEMVSSCONNECTION=https://dev.azure.com/*myOrg*/

@MartinPriebe
Copy link
Author

if a use a PAT for the connection it is working fine.

const authHandler = azdev.getPersonalAccessTokenHandler(pat)!; return new azdev.WebApi(orgUrl, authHandler);

So
const token = tl.getEndpointAuthorizationParameter('SYSTEMVSSCONNECTION', 'AccessToken', false)!;
cannot be used for it, right?

@ivanduplenskikh
Copy link

Hi @MartinPriebe thanks for reporting! We are working on more prioritized issues at the moment, but will get back to this one soon.

Copy link

This issue has had no activity in 90 days. Please comment if it is not actually stale

@github-actions github-actions bot added the stale label May 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants