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

Fix bug in WS error handling: ArgumentNullException #1039

Closed
pavel-mikula-sonarsource opened this issue Jul 27, 2021 · 0 comments · Fixed by #1048
Closed

Fix bug in WS error handling: ArgumentNullException #1039

pavel-mikula-sonarsource opened this issue Jul 27, 2021 · 0 comments · Fixed by #1048
Assignees
Milestone

Comments

@pavel-mikula-sonarsource
Copy link
Contributor

Setup

Let's have AZP YML file with an nonexistent organization key:

- task: SonarCloudPrepare@1
 inputs:
    SonarCloud: 'SonarCloud PayBySquare.NET Service Connection'
    organization: 'ThisIsInvalidValue'
    scannerMode: 'MSBuild'
    projectKey: 'Something'
    projectName: 'Something'

Error

It produces ArgumentNullException

2021-07-24T19:53:12.4529179Z ##[error]19:53:12.438  Failed to request and parse 'https://sonarcloud.io/api/qualityprofiles/search?project=Something&organization=ThisIsInvalidValue': Value cannot be null.
Parameter name: s

While the reported URL from SonarCloud
https://sonarcloud.io/api/qualityprofiles/search?project=Something&organization=ThisIsInvalidValue

returns clear error message that is not visible in the log

{"errors":[{"msg":"No organization with key \u0027ThisIsInvalidValue\u0027"}]}

Full log

2021-07-24T19:53:10.5219836Z ##[section]Starting: SonarCloudPrepare
2021-07-24T19:53:10.5404829Z ==============================================================================
2021-07-24T19:53:10.5405723Z Task         : Prepare Analysis Configuration
2021-07-24T19:53:10.5406376Z Description  : Prepare SonarCloud analysis configuration
2021-07-24T19:53:10.5406773Z Version      : 1.20.0
2021-07-24T19:53:10.5407289Z Author       : sonarsource
2021-07-24T19:53:10.5407953Z Help         : Version: 1.20.0. [More Information](https://sonarcloud.io/documentation/analysis/scan/sonarscanner-for-azure-devops/)
2021-07-24T19:53:10.5408765Z ==============================================================================
2021-07-24T19:53:11.6940202Z [command]D:\a\_tasks\SonarCloudPrepare_14d9cde6-c1da-4d55-aa01-2965cd301255\1.20.0\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe begin /k:Something /o:ThisIsInvalidValue
2021-07-24T19:53:11.8029673Z SonarScanner for MSBuild 5.2.1
2021-07-24T19:53:11.8037307Z Using the .NET Framework version of the Scanner for MSBuild
2021-07-24T19:53:11.8910853Z Pre-processing started.
2021-07-24T19:53:11.8944412Z Preparing working directories...
2021-07-24T19:53:12.0944275Z 19:53:12.093  Updating build integration targets...
2021-07-24T19:53:12.2988185Z 19:53:12.297  Fetching analysis configuration settings...
2021-07-24T19:53:12.4529179Z ##[error]19:53:12.438  Failed to request and parse 'https://sonarcloud.io/api/qualityprofiles/search?project=Something&organization=ThisIsInvalidValue': Value cannot be null.
Parameter name: s
2021-07-24T19:53:12.4550272Z 19:53:12.438  Failed to request and parse 'https://sonarcloud.io/api/qualityprofiles/search?project=Something&organization=ThisIsInvalidValue': Value cannot be null.
2021-07-24T19:53:12.4551520Z Parameter name: s
2021-07-24T19:53:12.4751840Z 
2021-07-24T19:53:12.4753780Z ##[error]Unhandled Exception:
2021-07-24T19:53:12.4895653Z ##[error]System.ArgumentNullException: Value cannot be null.
Parameter name: s
   at System.IO.StringReader..ctor(String s)
   at Newtonsoft.Json.Linq.JObject.Parse(String json, JsonLoadSettings settings)
   at SonarScanner.MSBuild.PreProcessor.SonarWebService.<>c__DisplayClass6_0.<<TryGetQualityProfile>b__0>d.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 SonarScanner.MSBuild.PreProcessor.SonarWebService.<DoLogExceptions>d__17`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 SonarScanner.MSBuild.PreProcessor.SonarWebService.<TryGetQualityProfile>d__6.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at SonarScanner.MSBuild.PreProcessor.TeamBuildPreProcessor.<FetchArgumentsAndRulesets>d__14.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 SonarScanner.MSBuild.PreProcessor.TeamBuildPreProcessor.<DoExecute>d__12.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 SonarScanner.MSBuild.PreProcessor.TeamBuildPreProcessor.<Execute>d__11.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 SonarScanner.MSBuild.BootstrapperClass.<PreProcess>d__9.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 SonarScanner.MSBuild.BootstrapperClass.<Execute>d__8.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 SonarScanner.MSBuild.Program.<Execute>d__4.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 SonarScanner.MSBuild.Program.<Execute>d__3.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 SonarScanner.MSBuild.Program.<Main>d__2.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 SonarScanner.MSBuild.Program.<Main>(String[] args)
2021-07-24T19:53:12.4916131Z System.ArgumentNullException: Value cannot be null.
2021-07-24T19:53:12.4918055Z Parameter name: s
2021-07-24T19:53:12.4919304Z    at System.IO.StringReader..ctor(String s)
2021-07-24T19:53:12.4920640Z    at Newtonsoft.Json.Linq.JObject.Parse(String json, JsonLoadSettings settings)
2021-07-24T19:53:12.4922138Z    at SonarScanner.MSBuild.PreProcessor.SonarWebService.<>c__DisplayClass6_0.<<TryGetQualityProfile>b__0>d.MoveNext()
2021-07-24T19:53:12.4923934Z --- End of stack trace from previous location where exception was thrown ---
2021-07-24T19:53:12.4925303Z    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
2021-07-24T19:53:12.4926793Z    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
2021-07-24T19:53:12.4928305Z    at SonarScanner.MSBuild.PreProcessor.SonarWebService.<DoLogExceptions>d__17`1.MoveNext()
2021-07-24T19:53:12.4929718Z --- End of stack trace from previous location where exception was thrown ---
2021-07-24T19:53:12.4931185Z    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
2021-07-24T19:53:12.4932690Z    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
2021-07-24T19:53:12.4934235Z    at SonarScanner.MSBuild.PreProcessor.SonarWebService.<TryGetQualityProfile>d__6.MoveNext()
2021-07-24T19:53:12.4935604Z --- End of stack trace from previous location where exception was thrown ---
2021-07-24T19:53:12.4936764Z    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
2021-07-24T19:53:12.4938013Z    at SonarScanner.MSBuild.PreProcessor.TeamBuildPreProcessor.<FetchArgumentsAndRulesets>d__14.MoveNext()
2021-07-24T19:53:12.4939340Z --- End of stack trace from previous location where exception was thrown ---
2021-07-24T19:53:12.4940563Z    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
2021-07-24T19:53:12.4941792Z    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
2021-07-24T19:53:12.4943327Z    at SonarScanner.MSBuild.PreProcessor.TeamBuildPreProcessor.<DoExecute>d__12.MoveNext()
2021-07-24T19:53:12.4944617Z --- End of stack trace from previous location where exception was thrown ---
2021-07-24T19:53:12.4945835Z    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
2021-07-24T19:53:12.4947946Z    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
2021-07-24T19:53:12.4949287Z    at SonarScanner.MSBuild.PreProcessor.TeamBuildPreProcessor.<Execute>d__11.MoveNext()
2021-07-24T19:53:12.4950526Z --- End of stack trace from previous location where exception was thrown ---
2021-07-24T19:53:12.4951712Z    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
2021-07-24T19:53:12.4954525Z    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
2021-07-24T19:53:12.4955821Z    at SonarScanner.MSBuild.BootstrapperClass.<PreProcess>d__9.MoveNext()
2021-07-24T19:53:12.4957004Z --- End of stack trace from previous location where exception was thrown ---
2021-07-24T19:53:12.4958204Z    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
2021-07-24T19:53:12.4959460Z    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
2021-07-24T19:53:12.4960725Z    at SonarScanner.MSBuild.BootstrapperClass.<Execute>d__8.MoveNext()
2021-07-24T19:53:12.4961905Z --- End of stack trace from previous location where exception was thrown ---
2021-07-24T19:53:12.4963114Z    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
2021-07-24T19:53:12.4964577Z    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
2021-07-24T19:53:12.4966517Z    at SonarScanner.MSBuild.Program.<Execute>d__4.MoveNext()
2021-07-24T19:53:12.4967557Z --- End of stack trace from previous location where exception was thrown ---
2021-07-24T19:53:12.4968548Z    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
2021-07-24T19:53:12.4969560Z    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
2021-07-24T19:53:12.4970770Z    at SonarScanner.MSBuild.Program.<Execute>d__3.MoveNext()
2021-07-24T19:53:12.4971898Z --- End of stack trace from previous location where exception was thrown ---
2021-07-24T19:53:12.4972860Z    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
2021-07-24T19:53:12.4973865Z    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
2021-07-24T19:53:12.4974853Z    at SonarScanner.MSBuild.Program.<Main>d__2.MoveNext()
2021-07-24T19:53:12.4975759Z --- End of stack trace from previous location where exception was thrown ---
2021-07-24T19:53:12.4976714Z    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
2021-07-24T19:53:12.4977712Z    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
2021-07-24T19:53:12.4979591Z 
2021-07-24T19:53:12.5071442Z ##[error]The process 'D:\a\_tasks\SonarCloudPrepare_14d9cde6-c1da-4d55-aa01-2965cd301255\1.20.0\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe' failed with exit code 3762504530
2021-07-24T19:53:12.5273788Z ##[section]Finishing: SonarCloudPrepare
@pavel-mikula-sonarsource pavel-mikula-sonarsource added this to To do in S4NET Kanban via automation Aug 9, 2021
@pavel-mikula-sonarsource pavel-mikula-sonarsource added this to the 5.3.0 milestone Aug 9, 2021
@pavel-mikula-sonarsource pavel-mikula-sonarsource moved this from To do to In progress in S4NET Kanban Aug 12, 2021
@pavel-mikula-sonarsource pavel-mikula-sonarsource changed the title Bug in WS error handling: ArgumentNullException Fix bug in WS error handling: ArgumentNullException Aug 13, 2021
@pavel-mikula-sonarsource pavel-mikula-sonarsource moved this from In progress to Review in progress in S4NET Kanban Aug 13, 2021
@csaba-sagi-sonarsource csaba-sagi-sonarsource moved this from Review in progress to Reviewer approved in S4NET Kanban Aug 13, 2021
@pavel-mikula-sonarsource pavel-mikula-sonarsource moved this from Reviewer approved to Done in S4NET Kanban Aug 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
S4NET Kanban
  
Done
Development

Successfully merging a pull request may close this issue.

3 participants