Failed: SyntaxError: invalid syntax (<string>, line 1)

Hello everyone,
I’m looking to resolve the following error :

'signature': "<?xml version='1.0' encoding='UTF-8' standalone='no'?><svg xmlns='http://www.w3.org/2000/svg' version='1.2' baseProfile='tiny' height='1219' width='996' viewBox='0 0 996 1219'><g stroke-linejoin='round' stroke-linecap='round' fill='none' stroke='black'><path stroke-width='16' d='M147,894c0,0 0,0 0,0 '/><path stroke-width='18' d='M147,894c0,-1 0,-1 0,-2 '/><path stroke-width='13' d='M147,892c3,-7 3,-7 6,-13 '/><path stroke-width='8' d='M153,879c5,-9 6,-9 11,-18 6,-11 5,-12 10,-24 7,-16 8,-16 15,-32 8,-20 8,-19 16,-39 8,-21 7,-21 14,-42 8,-22 9,-22 17,-43 9,-25 9,-25 17,-49 8,-22 9,-22 15,-44 7,-24 6,-24 1...
[ Message content over the limit has been removed. ] ...0,5 '/><path stroke-width='11' d='M816,589c0,5 0,5 0,9 '/><path stroke-width='9' d='M816,598c0,6 0,6 0,12 0,8 0,8 0,16 '/><path stroke-width='8' d='M816,626c0,9 0,9 0,18 0,11 0,11 0,22 0,15 0,15 1,29 1,17 2,17 3,34 2,16 2,16 3,32 2,16 2,16 3,33 2,15 2,15 4,31 2,14 2,14 4,27 2,12 3,12 4,25 2,10 2,10 3,20 2,11 3,11 4,22 2,8 2,8 2,16 1,5 0,5 0,11 '/><path stroke-width='9' d='M847,946c0,4 -1,4 0,8 '/><path stroke-width='12' d='M847,954c0,1 1,1 2,2 '/><path stroke-width='15' d='M849,956c1,1 1,1 1,1 '/><path stroke-width='16' d='M850,957c1,0 1,0 1,0 1,0 2,1 2,0 '/><path stroke-width='14' d='M853,957c2,-2 2,-2 3,-5 '/><path stroke-width='11' d='M856,952c0,-2 0,-2 0,-5 '/><path stroke-width='13' d='M883,324c0,0 0,0 0,0 '/><path stroke-width='16' d='M883,324c-3,1 -3,0 -5,2 '/><path stroke-width='12' d='M878,326c-6,3 -6,4 -11,8 '/><path stroke-width='8' d='M867,334c-6,6 -7,5 -12,11 -7,7 -6,8 -12,15 -6,10 -6,10 -12,19 -5,11 -6,10 -10,22 -4,11 -4,11 -6,23 -2,9 -3,10 -2,18 1,7 2,7 6,12 5,7 5,8 11,13 5,4 6,4 12,6 9,3 9,3 18,4 9,1 9,1 18,0 9,-1 10,-1 18,-4 11,-4 11,-5 21,-11 10,-7 10,-7 19,-16 8,-8 8,-8 14,-18 7,-10 9,-10 12,-22 3,-10 2,-11 2,-22 0,-7 -1,-7 -3,-14 -2,-8 -1,-8 -5,-15 -5,-8 -5,-8 -13,-14 -8,-6 -9,-4 -18,-9 -8,-4 -7,-6 -14,-9 -6,-3 -6,-4 -13,-5 '/><path stroke-width='9' d='M898,318c-4,-1 -5,-1 -8,0 '/><path stroke-width='10' d='M890,318c-4,1 -4,3 -7,5 '/><path stroke-width='9' d='M883,323c-5,5 -7,6 -11,9 '/><path stroke-width='9' d='M883,323c-5,5 -7,6 -11,9 '/></g></svg>"}"==""' failed: SyntaxError: invalid syntax (<string>, line 1)------------------------------------------------------------------------------Marge Backend-Testcases                                               | FAIL |1 test, 0 passed, 1 failed

The executed keyword is as follow :

Exemple
[Arguments]    ${client}
&{headers}=    Create Dictionary    x-marge-test-account=${client}
Log To Console    The header is ==============> &{headers}
${onboarding_token}=    Token_Example    ${client}
Log To Console    The onboarding token is ==============> ${onboarding_token}
${svg}=    Get File    svg_content.txt
Log    ${svg}
Log To Console    The svg file is ==============> ${svg}
${signature_body}=    Create Dictionary    onboardingToken=${onboarding_token}    signature=${svg}
${resp}=    Post-Request    customers/me/onboarding/contract    ${headers}    ${signature_body}

I’m looking to identify the cause of the problem.
Any help will be appreciated.

Hard to know at which point it is falling over as the output you’ve shared was limited in the logging “[ Message content over the limit has been removed. ]” if you are using Pycharm you can increase this by increasing the console size values in settings.

But providing the output logs would be helpful in any case which will highlight at which point it is falling over, but also what you could do is comment out all statements, and work your way down uncommenting and running your test to see at which point it’s falling over (it’s just hard to know from the error you shared as it’s limited) the error is as it reads though: “failed: SyntaxError: invalid syntax (, line 1)” possibly the Get File line is the cause? if so then its possible to pass arguments "encoding_errors = " and values strict, ignore and replace

Sorry it’s not as helpful

2 Likes

Good that content over limit has been removed, because it looks like some secret content :wink:

Seem s that the problematic part is that comparison because of the double-quotes:
(d='M883,323c-5,5 -7,6 -11,9 '/></g></svg>"}"==""')
As you don’t have that condition in the visible code, I assume it is inside the keyword Token_Example or from the Post-Request ( RequestsLibrary?).

Did the Log and Log To Console steps worked?

(You really should improve the way you ask for help, starting for the title of the Topic)

2 Likes