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

Deprecated warning message part of stdout instead of stderr resulting in invalid json response #1896

Closed
jguay opened this issue Jan 25, 2023 · 5 comments
Labels
bug Issue or pull request that identifies or fixes a bug

Comments

@jguay
Copy link

jguay commented Jan 25, 2023

sfdx version 7.184.2 using deprecated function and redirecting stderr to /dev/null, the output is invalid json as the json is prefixed by some non json text Warning... that does not respect json formatting rules:

$ sfdx force:data:soql:query -r json -q "${query}" 2>/dev/null | head -2
Warning: The "force data soql query" command has been deprecated. Use "data query" instead.
{

This deprecation warning is a breaking change, assume I don't control the sfdx version, the new data query does not work on older sfdx version and we now have to do 2 things to fix this :

  1. The main and immediate workaround we have put in place is to remove the first line of json output if it starts with Warning - I expect warning should be sent to stderr then there would not be any issue (we capture stderr to logs but that would not break automations)...
  2. And we'll add code to check sfdx version is lower or higher than 7.184.2 to call the new methods which did not exist in previous version
@jguay jguay added the investigating We're actively investigating this issue label Jan 25, 2023
@github-actions
Copy link

Thank you for filing this issue. We appreciate your feedback and will review the issue as soon as possible. Remember, however, that GitHub isn't a mechanism for receiving support under any agreement or SLA. If you require immediate assistance, contact Salesforce Customer Support.

@WillieRuemmele
Copy link
Member

Hi @jguay , thanks for reporting this issue! I was able to reproduce it, but also found a workaround.

➜  dreamhouse-lwc git:(main) ✗  hub:(GLOBAL - DevHub) scratch:([email protected])
 ➜  sfdx force:data:soql:query -q "SELECT MemberName, MemberType FROM SourceMember" --json -t 2>/dev/null | head -2  
{
  "status": 0,
➜  dreamhouse-lwc git:(main) ✗  hub:(GLOBAL - DevHub) scratch:([email protected])
 ➜  sfdx force:data:soql:query -q "SELECT MemberName, MemberType FROM SourceMember" -r json -t 2>/dev/null | head -2
Warning: The "force data soql query" command has been deprecated. Use "data query" instead.
{

instead of using -r json, just using the --json flag

@WillieRuemmele WillieRuemmele added bug Issue or pull request that identifies or fixes a bug and removed investigating We're actively investigating this issue labels Jan 25, 2023
@git2gus
Copy link

git2gus bot commented Jan 25, 2023

This issue has been linked to a new work item: W-12436551

@jguay
Copy link
Author

jguay commented Jan 25, 2023

Thank you @WillieRuemmele --json option works perfectly all warnings end up in JSON payload in array .warnings[], this is the exact behaviour we needed for our automation

@mshanemc
Copy link
Contributor

duplicate of #1926

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue or pull request that identifies or fixes a bug
Projects
None yet
Development

No branches or pull requests

3 participants