postmanlabs / postman-code-generators

Common repository for all code generators shipped with Postman
Apache License 2.0
992 stars 351 forks source link

cURL Breaking without `-g` #253

Closed chaffeqa closed 3 years ago

chaffeqa commented 4 years ago

Describe the bug When using GraphQL query bodies in GET requests, the codegen cURL will fail with curl: (3) nested brace in URL position 122:. However it will pass if -g is added to the request.

To Reproduce Steps to reproduce the behavior:

curl --location --request GET 'https://picks-dev.cbssports.com/graphql?query=query%20APIBracketLobbyQuery%20{%0A%20%20bpc:%20gameInstance(game:%20{%20uid:%20%22cbs-ncaab-tournament-challenge%22%20})%20{%0A%20%20%20%20...APIGameInstanceFragment%0A%20%20}%0A%20%20bpm:%20gameInstance(game:%20{%20uid:%20%22cbs-ncaab-tournament-manager%22%20})%20{%0A%20%20%20%20...APIGameInstanceFragment%0A%20%20}%0A%20%20currentUser%20{%0A%20%20%20%20preferredEntryName%0A%20%20%20%20bpcEntries:%20entries(%0A%20%20%20%20%20%20first:%20200%0A%20%20%20%20%20%20gameInstanceUid:%20%22cbs-ncaab-tournament-challenge%22%0A%20%20%20%20)%20{%0A%20%20%20%20%20%20edges%20{%0A%20%20%20%20%20%20%20%20node%20{%0A%20%20%20%20%20%20%20%20%20%20...APILobbyEntryFragment%0A%20%20%20%20%20%20%20%20}%0A%20%20%20%20%20%20}%0A%20%20%20%20}%0A%20%20%20%20bpmEntries:%20entries(%0A%20%20%20%20%20%20first:%20200%0A%20%20%20%20%20%20gameInstanceUid:%20%22cbs-ncaab-tournament-manager%22%0A%20%20%20%20)%20{%0A%20%20%20%20%20%20edges%20{%0A%20%20%20%20%20%20%20%20node%20{%0A%20%20%20%20%20%20%20%20%20%20...APILobbyEntryFragment%0A%20%20%20%20%20%20%20%20}%0A%20%20%20%20%20%20}%0A%20%20%20%20}%0A%20%20}%0A}%0Afragment%20APIGameInstanceFragment%20on%20GameInstance%20{%0A%20%20uid%0A%20%20seasons(first:%20100)%20{%0A%20%20%20%20edges%20{%0A%20%20%20%20%20%20node%20{%0A%20%20%20%20%20%20%20%20id%0A%20%20%20%20%20%20%20%20year%0A%20%20%20%20%20%20%20%20masterProductId%0A%20%20%20%20%20%20%20%20productAbbrev%0A%20%20%20%20%20%20%20%20challengePoolId%0A%20%20%20%20%20%20}%0A%20%20%20%20}%0A%20%20}%0A%20%20currentPeriod%20{%0A%20%20%20%20...APILobbyCurrentPeriodFragment%0A%20%20}%0A}%0Afragment%20APILobbyCurrentPeriodFragment%20on%20Period%20{%0A%20%20locksAt%0A%20%20isPickable%0A%20%20segment%20{%0A%20%20%20%20shouldPromoteToPlay%0A%20%20%20%20season%20{%0A%20%20%20%20%20%20id%0A%20%20%20%20%20%20masterProductId%0A%20%20%20%20%20%20challengePoolId%0A%20%20%20%20}%0A%20%20}%0A}%0Afragment%20APILobbyEntryFragment%20on%20Entry%20{%0A%20%20id%0A%20%20name%0A%20%20fantasyPoints%0A%20%20poolRank%0A%20%20url%0A%20%20needsToMakePicks%0A%20%20avatarUrl%0A%20%20periodPoint%20{%0A%20%20%20%20poolRank%0A%20%20%20%20fantasyPoints%0A%20%20}%0A%20%20pool%20{%0A%20%20%20%20id%0A%20%20%20%20name%0A%20%20%20%20url%0A%20%20%20%20season%20{%0A%20%20%20%20%20%20masterProductId%0A%20%20%20%20}%0A%20%20}%0A}%0A'

vs

curl -g --location --request GET 'https://picks-dev.cbssports.com/graphql?query=query%20APIBracketLobbyQuery%20{%0A%20%20bpc:%20gameInstance(game:%20{%20uid:%20%22cbs-ncaab-tournament-challenge%22%20})%20{%0A%20%20%20%20...APIGameInstanceFragment%0A%20%20}%0A%20%20bpm:%20gameInstance(game:%20{%20uid:%20%22cbs-ncaab-tournament-manager%22%20})%20{%0A%20%20%20%20...APIGameInstanceFragment%0A%20%20}%0A%20%20currentUser%20{%0A%20%20%20%20preferredEntryName%0A%20%20%20%20bpcEntries:%20entries(%0A%20%20%20%20%20%20first:%20200%0A%20%20%20%20%20%20gameInstanceUid:%20%22cbs-ncaab-tournament-challenge%22%0A%20%20%20%20)%20{%0A%20%20%20%20%20%20edges%20{%0A%20%20%20%20%20%20%20%20node%20{%0A%20%20%20%20%20%20%20%20%20%20...APILobbyEntryFragment%0A%20%20%20%20%20%20%20%20}%0A%20%20%20%20%20%20}%0A%20%20%20%20}%0A%20%20%20%20bpmEntries:%20entries(%0A%20%20%20%20%20%20first:%20200%0A%20%20%20%20%20%20gameInstanceUid:%20%22cbs-ncaab-tournament-manager%22%0A%20%20%20%20)%20{%0A%20%20%20%20%20%20edges%20{%0A%20%20%20%20%20%20%20%20node%20{%0A%20%20%20%20%20%20%20%20%20%20...APILobbyEntryFragment%0A%20%20%20%20%20%20%20%20}%0A%20%20%20%20%20%20}%0A%20%20%20%20}%0A%20%20}%0A}%0Afragment%20APIGameInstanceFragment%20on%20GameInstance%20{%0A%20%20uid%0A%20%20seasons(first:%20100)%20{%0A%20%20%20%20edges%20{%0A%20%20%20%20%20%20node%20{%0A%20%20%20%20%20%20%20%20id%0A%20%20%20%20%20%20%20%20year%0A%20%20%20%20%20%20%20%20masterProductId%0A%20%20%20%20%20%20%20%20productAbbrev%0A%20%20%20%20%20%20%20%20challengePoolId%0A%20%20%20%20%20%20}%0A%20%20%20%20}%0A%20%20}%0A%20%20currentPeriod%20{%0A%20%20%20%20...APILobbyCurrentPeriodFragment%0A%20%20}%0A}%0Afragment%20APILobbyCurrentPeriodFragment%20on%20Period%20{%0A%20%20locksAt%0A%20%20isPickable%0A%20%20segment%20{%0A%20%20%20%20shouldPromoteToPlay%0A%20%20%20%20season%20{%0A%20%20%20%20%20%20id%0A%20%20%20%20%20%20masterProductId%0A%20%20%20%20%20%20challengePoolId%0A%20%20%20%20}%0A%20%20}%0A}%0Afragment%20APILobbyEntryFragment%20on%20Entry%20{%0A%20%20id%0A%20%20name%0A%20%20fantasyPoints%0A%20%20poolRank%0A%20%20url%0A%20%20needsToMakePicks%0A%20%20avatarUrl%0A%20%20periodPoint%20{%0A%20%20%20%20poolRank%0A%20%20%20%20fantasyPoints%0A%20%20}%0A%20%20pool%20{%0A%20%20%20%20id%0A%20%20%20%20name%0A%20%20%20%20url%0A%20%20%20%20season%20{%0A%20%20%20%20%20%20masterProductId%0A%20%20%20%20}%0A%20%20}%0A}%0A'

Expected code snippet and corresponding request Add -g to all cURL requests by default or properly deal with double vs single quotes (https://github.com/postmanlabs/postman-code-generators/pull/251)

Additional context collection: 11254382-24f763ba-01f6-4782-85c5-f65f3809457b Version of postman-code-generators/Postman app: Version 7.24.0 (7.24.0)

someshkoli commented 4 years ago

@chaffeqa can you give an example on how handling quotes can fix this issue ?

chaffeqa commented 4 years ago

Honestly I didnt really figure that out, but I'm sure its a quoting issue (since the SO solution mentions that and I know that we are dealing with quotes here)... the -g seems to solve the issue though right? Maybe its as simple as always including -g on all GraphQL GET requests?

someshkoli commented 4 years ago

I guess its not just graphql, curl doesn't accept multiple braces in url and requires a -g option. I tried a few and figured this out ^

chaffeqa commented 4 years ago

ooooo its the braces! thx for figuring that out, the quotes stuff seemed the obvious to me, never thought bout braces