sevaa / dumpagentcaps

Azure DevOps extension for dumping the user defined capabilities of the current agent
0 stars 0 forks source link

No agent found #1

Open TekuSP opened 3 years ago

TekuSP commented 3 years ago
Starting: DumpAgentCaps
==============================================================================
Task         : Dump user defined capabilities of the current agent
Description  : Creates and populates a set of build/release variables based on the user defined capabilities of the agent that's executing the task
Version      : 1.0.2
Author       : Seva Alekseyev
Help         : 
==============================================================================
##[warning]Task 'Dump Agent Caps' (1.0.2) is using deprecated task execution handler. The task should use the supported task-lib: https://aka.ms/tasklib
Preparing task execution handler.
Executing the powershell script: D:\Devops_Agent\_work\_tasks\Dump Agent Caps_dfff8d44-0d26-4b0d-96e9-44f333de503c\1.0.2\DumpAgentCaps.ps1
##[error]System.Management.Automation.MethodInvocationException: Exception calling "GetResult" with "0" argument(s): "No agent found for pool 1 with identifier 13." ---> Microsoft.TeamFoundation.DistributedTask.WebApi.TaskAgentNotFoundException: No agent found for pool 1 with identifier 13.
   at Microsoft.VisualStudio.Services.WebApi.VssHttpClientBase.<HandleResponseAsync>d__51.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.Services.WebApi.VssHttpClientBase.<SendAsync>d__49.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.Services.WebApi.VssHttpClientBase.<SendAsync>d__46`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.Services.WebApi.VssHttpClientBase.<SendAsync>d__27`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at CallSite.Target(Closure , CallSite , Object )
   --- End of inner exception stack trace ---
TekuSP commented 3 years ago

This is to uncorrect rights set, but, error should be more clear for user to understand.

sevaa commented 3 years ago

As you can see, the exception from the underlying API is not really telling me it's a user rights error.

The exception class is MethodInvocationException and the exception message is "No agent found for pool 1 with identifier 13." That's all you have to work with. The error class is generic, and I don't like the idea of parsing an error message.

TekuSP commented 3 years ago

Can you call API to verify user gave you account/token with right permissions? https://docs.microsoft.com/en-us/rest/api/azure/devops/security/permissions/has%20permissions?view=azure-devops-rest-6.0

sevaa commented 3 years ago

On general grounds, if a user is unable to read the properties of an agent, the same user won't be able to check the permissions on the agent, either. And this is all over a more descriptive error message.

I think I'll add a generic "Please check the permissions" to the message.