maikvandergaag / msft-extensions

Repository for extensions mainly used for Azure DevOps Extensions
https://msftplayground.com
MIT License
125 stars 81 forks source link

Update parameter issue #423

Closed ctimoftey closed 2 years ago

ctimoftey commented 2 years ago

Describe the issue Hi Maik, I have issue with your update parameter action. Example our sql instance and db contains "\" {"name":"sqlserver","newValue":"SomeServerInstance\\ServerNamexxx"} so if I pass this valid json PowerBIActions@5 update parameter action this will fail throwing error "Bad request" because our sql server instance is SomeServerInstance\ServerNamexxx
If I pass the this json {"name":"sqlserver","newValue":"SomeServerInstance\ServerNamexxx"} it will fail because is not well formatted

[error]Supplied json is not in the correct format!

Extension

To Reproduce Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior A clear and concise description of what you expected to happen.

Situation (please complete the following information):

Log info Please add the log file of the agent in debug mode [Add the variable system.debug with the value 'true ' to your pipeline]

Additional information Add any other context about the problem here.

maikvandergaag commented 2 years ago

Could your share the debug logs of both the runs?

ctimoftey commented 2 years ago

Hi Maik This is the partial log only for the update parameter action when in json I have "SomeServerInstance\\ServerNamexxx" (with double backslash)

[debug]Trying to invoke api: https://api.powerbi.com/v1.0/myorg/groups/26cbf1a7-2388-4bab-bf03-5d90cc3bca55/datasets/442500b4-95c1-40b7-9a9f-00a63789a067/Default.UpdateParameters

[debug]POST https://api.powerbi.com/v1.0/myorg/groups/26cbf1a7-2388-4bab-bf03-5d90cc3bca55/datasets/442500b4-95c1-40b7-9a9f-00a63789a067/Default.UpdateParameters with -1-byte payload

Done processing Power BI Actions

[debug]Caught exception from task script.

[debug]Error record:

[debug]Invoke-API : BadRequest

[debug]At D:\a_tasks\PowerBIActions_d5b7fec6-2b25-4742-905b-0dad97687df5\5.4.38\ps_modules\PowerBI\PowerBI.psm1:238 char:9

[debug]+ Invoke-API -Url $url -Method "Post" -Body $body -ContentType ...

[debug]+ ~~~~~~~~~~~~~

[debug] + CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException

[debug] + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Invoke-API

[debug]

[debug]Script stack trace:

[debug]at Invoke-API, D:\a_tasks\PowerBIActions_d5b7fec6-2b25-4742-905b-0dad97687df5\5.4.38\ps_modules\PowerBI\PowerBI.psm1: line 307

[debug]at Update-PowerBIDatasetParameter, D:\a_tasks\PowerBIActions_d5b7fec6-2b25-4742-905b-0dad97687df5\5.4.38\ps_modules\PowerBI\PowerBI.psm1: line 238

[debug]at Update-PowerBIDatasetParameters, D:\a_tasks\PowerBIActions_d5b7fec6-2b25-4742-905b-0dad97687df5\5.4.38\ps_modules\PowerBI\PowerBI.psm1: line 256

[debug]at , D:\a_tasks\PowerBIActions_d5b7fec6-2b25-4742-905b-0dad97687df5\5.4.38\run.ps1: line 208

[debug]at , : line 1

[debug]at , : line 22

[debug]at , : line 18

[debug]at , : line 1

[debug]Exception:

[debug]Microsoft.PowerShell.Commands.WriteErrorException: BadRequest

[error]BadRequest

[debug]Processed: ##vso[task.logissue type=error]BadRequest

[debug]Processed: ##vso[task.complete result=Failed]

Finishing: Update parameter for Report

ctimoftey commented 2 years ago

Hi Maik When I have in my json "SomeServerInstance\ServerNamexxx" (with one backslash) it fails even before your action (it fails at my action when I I parse the json from my config in the repo) error bellow

ConvertFrom-Json : Unrecognized escape sequence. (253): {

maikvandergaag commented 2 years ago

I think that is because the \ is a escape token on json try to do \

ctimoftey commented 2 years ago

Hi Maik, If I only use one backslash in my workspaceconfig.json file then at my parsing phase I get error (that is before your actions): ConvertFrom-Json : Unrecognized escape sequence. (253)

If I use 2 backslashes in my workspaceconfig.json file then all the actions are good without errors but the parameters are not updated...

ctimoftey commented 2 years ago

Hi Maik, Before your actions when I parse my workspaceconfig.json here is the value from parsed json only for the parameters section: @{name=sqlserver; newValue=SomeServerInstance\Someinstance_name}

But then I need to convert this back to json and compress it Here is the new paramerter back to json and compresses {"name":"sqlserver","newValue":"SomeServerInstance\\Someinstance_name"}

This will fail since there is no such instance with double backslahs

ctimoftey commented 2 years ago

Hi Maik I even hardcoded the json value inside your action:

(single blackslash for the sql parameter)

It will fail saying : ##[error]Supplied json is not in the correct format

ctimoftey commented 2 years ago

Hi Maik,

Here are the debug logs for both

Error system.debug=true when using double backslash with hardcoded json value inside your action:

2022-07-21T02:29:06.6545655Z Done processing Power BI Actions 2022-07-21T02:29:06.6657690Z ##[debug]Caught exception from task script. 2022-07-21T02:29:06.6696264Z ##[debug]Error record: 2022-07-21T02:29:06.7539225Z ##[debug]Invoke-API : BadRequest 2022-07-21T02:29:06.7599250Z ##[debug]At D:\a_tasks\PowerBIActions_d5b7fec6-2b25-4742-905b-0dad97687df5\5.4.38\ps_modules\PowerBI\PowerBI.psm1:238 char:9 2022-07-21T02:29:06.7640287Z ##[debug]+ Invoke-API -Url $url -Method "Post" -Body $body -ContentType ... 2022-07-21T02:29:06.7641237Z ##[debug]+ ~~~~~~~~~~~~~ 2022-07-21T02:29:06.7642829Z ##[debug] + CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException 2022-07-21T02:29:06.7658820Z ##[debug] + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Invoke-API 2022-07-21T02:29:06.7675685Z ##[debug] 2022-07-21T02:29:06.7702071Z ##[debug]Script stack trace: 2022-07-21T02:29:06.7776892Z ##[debug]at Invoke-API, D:\a_tasks\PowerBIActions_d5b7fec6-2b25-4742-905b-0dad97687df5\5.4.38\ps_modules\PowerBI\PowerBI.psm1: line 307 2022-07-21T02:29:06.7808287Z ##[debug]at Update-PowerBIDatasetParameter, D:\a_tasks\PowerBIActions_d5b7fec6-2b25-4742-905b-0dad97687df5\5.4.38\ps_modules\PowerBI\PowerBI.psm1: line 238 2022-07-21T02:29:06.7824277Z ##[debug]at Update-PowerBIDatasetParameters, D:\a_tasks\PowerBIActions_d5b7fec6-2b25-4742-905b-0dad97687df5\5.4.38\ps_modules\PowerBI\PowerBI.psm1: line 256 2022-07-21T02:29:06.7882187Z ##[debug]at , D:\a_tasks\PowerBIActions_d5b7fec6-2b25-4742-905b-0dad97687df5\5.4.38\run.ps1: line 208 2022-07-21T02:29:06.7900655Z ##[debug]at , : line 1 2022-07-21T02:29:06.7920412Z ##[debug]at , : line 22 2022-07-21T02:29:06.7950418Z ##[debug]at , : line 18 2022-07-21T02:29:06.8002930Z ##[debug]at , : line 1 2022-07-21T02:29:06.8029999Z ##[debug]Exception: 2022-07-21T02:29:06.8121501Z ##[debug]Microsoft.PowerShell.Commands.WriteErrorException: BadRequest 2022-07-21T02:29:06.8365429Z ##[error]BadRequest 2022-07-21T02:29:06.8366412Z ##[debug]Processed: ##vso[task.logissue type=error]BadRequest 2022-07-21T02:29:06.8386075Z ##[debug]Processed: ##vso[task.complete result=Failed] 2022-07-21T02:29:06.8710699Z ##[section]Finishing: Update parameter for Report

Error system.debug=true when using single backslash hardcoded json value inside your action:

2022-07-21T02:34:03.5782269Z Done processing Power BI Actions 2022-07-21T02:34:03.5868796Z ##[debug]Caught exception from task script. 2022-07-21T02:34:03.5910056Z ##[debug]Error record: 2022-07-21T02:34:03.6655639Z ##[debug]D:\a_tasks\PowerBIActions_d5b7fec6-2b25-4742-905b-0dad97687df5\5.4.38\run.ps1 : Supplied json is not in the correct format! 2022-07-21T02:34:03.6675742Z ##[debug]At line:1 char:1 2022-07-21T02:34:03.6690607Z ##[debug]+ . 'D:\a_tasks\PowerBIActions_d5b7fec6-2b25-4742-905b-0dad97687df5\5. ... 2022-07-21T02:34:03.6705675Z ##[debug]+ ~~~~~~~~~~~~~~~~~ 2022-07-21T02:34:03.6720665Z ##[debug] + CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException 2022-07-21T02:34:03.6735863Z ##[debug] + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,run.ps1 2022-07-21T02:34:03.6752230Z ##[debug] 2022-07-21T02:34:03.6772735Z ##[debug]Script stack trace: 2022-07-21T02:34:03.6873869Z ##[debug]at , D:\a_tasks\PowerBIActions_d5b7fec6-2b25-4742-905b-0dad97687df5\5.4.38\run.ps1: line 199 2022-07-21T02:34:03.6889469Z ##[debug]at , : line 1 2022-07-21T02:34:03.6904372Z ##[debug]at , : line 22 2022-07-21T02:34:03.6921974Z ##[debug]at , : line 18 2022-07-21T02:34:03.6938061Z ##[debug]at , : line 1 2022-07-21T02:34:03.6962932Z ##[debug]Exception: 2022-07-21T02:34:03.7011450Z ##[debug]Microsoft.PowerShell.Commands.WriteErrorException: Supplied json is not in the correct format! 2022-07-21T02:34:03.7307432Z ##[error]Supplied json is not in the correct format! 2022-07-21T02:34:03.7308345Z ##[debug]Processed: ##vso[task.logissue type=error]Supplied json is not in the correct format! 2022-07-21T02:34:03.7319139Z ##[debug]Processed: ##vso[task.complete result=Failed] 2022-07-21T02:34:03.7605789Z ##[section]Finishing: Update parameter for Report

maikvandergaag commented 2 years ago

Thanks, will investigate further when I am back holiday. Are you using a datagateway in between?

ctimoftey commented 2 years ago

Hi Maik Yes we have gateway because our SQL and Oracle are on premise Your PowerBi Action to update parameter works perfect for Oracle dataset but for SQL we have this issue because of the databaseserver\instance (the backslash escape issue)

Thank you G

ctimoftey commented 2 years ago

Hi Maik, You can close this issue So yes we have gateway and if we use databaseserver\\\\instance then the update paramter action works TY G

ctimoftey commented 2 years ago

I close this issue as it seems I found the solution

maikvandergaag commented 2 years ago

Thanks for the update