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

Malformed payload when listing projects #11

Open
psy-q opened this issue Feb 2, 2017 · 6 comments
Open

Malformed payload when listing projects #11

psy-q opened this issue Feb 2, 2017 · 6 comments

Comments

@psy-q
Copy link
Contributor

psy-q commented Feb 2, 2017

I had to mess around a bit because I was unable to make import.php connect to a server with an invalid certificate. That's why I switched to a newer version of json-rpc in #9 so that I could disable cert verification.

After that I still couldn't make it work. Below is a log with debug enabled. I verified that it works fine when done manually using curl. Curl example is on the bottom.

# These are some debug var_dumps that I stuck there, to make sure the payload
# is passed correctly
in execute:string(57) "{"jsonrpc":"2.0","method":"getAllProjects","id":17746587}"
in sendPayload:string(57) "{"jsonrpc":"2.0","method":"getAllProjects","id":17746587}"
in sendPayload but after execute:==> Request: 
{"jsonrpc":"2.0","method":"getAllProjects","id":17746587}
==> Headers: 
array (
  0 => 'HTTP/1.1 302 Found',
  1 => 'Date: Thu, 02 Feb 2017 12:26:51 GMT',
  2 => 'Server: Apache/2.4.10 (Debian)',
  3 => 'Set-Cookie: KB_SID=BZD-E9IHesgk2FxuWWPzJrqGeS8; path=/; secure; HttpOnly',
  4 => 'Expires: Thu, 19 Nov 1981 08:52:00 GMT',
  5 => 'Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0',
  6 => 'Pragma: no-cache',
  7 => 'Content-Security-Policy: default-src \'self\'; style-src \'self\' \'unsafe-inline\'; img-src * data:;',
  8 => 'X-Content-Type-Options: nosniff',
  9 => 'X-XSS-Protection: 1; mode=block',
  10 => 'P3P: CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"',
  11 => 'X-Frame-Options: DENY',
  12 => 'Strict-Transport-Security: max-age=31536000',
  13 => 'Location: /?controller=AuthController&action=login',
  14 => 'Content-Length: 0',
  15 => 'Connection: close',
  16 => 'Content-Type: text/html; charset=UTF-8',
  17 => 'HTTP/1.1 200 OK',
  18 => 'Date: Thu, 02 Feb 2017 12:26:52 GMT',
  19 => 'Server: Apache/2.4.10 (Debian)',
  20 => 'Set-Cookie: KB_SID=8fr%2CdO7xUpS%2CAzUMqfwB5iMVDH2; path=/; secure; HttpOnly',
  21 => 'Expires: Thu, 19 Nov 1981 08:52:00 GMT',
  22 => 'Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0',
  23 => 'Pragma: no-cache',
  24 => 'Content-Security-Policy: default-src \'self\'; style-src \'self\' \'unsafe-inline\'; img-src * data:;',
  25 => 'X-Content-Type-Options: nosniff',
  26 => 'X-XSS-Protection: 1; mode=block',
  27 => 'P3P: CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"',
  28 => 'X-Frame-Options: DENY',
  29 => 'Strict-Transport-Security: max-age=31536000',
  30 => 'Vary: Accept-Encoding',
  31 => 'Content-Length: 4848',
  32 => 'Connection: close',
  33 => 'Content-Type: text/html; charset=utf-8',
)
==> Response: 
null
NULL
==> Request: 
{"jsonrpc":"2.0","method":"getAllProjects","id":17746587}
==> Headers: 
array (
  0 => 'HTTP/1.1 302 Found',
  1 => 'Date: Thu, 02 Feb 2017 12:26:52 GMT',
  2 => 'Server: Apache/2.4.10 (Debian)',
  3 => 'Expires: Thu, 19 Nov 1981 08:52:00 GMT',
  4 => 'Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0',
  5 => 'Pragma: no-cache',
  6 => 'Content-Security-Policy: default-src \'self\'; style-src \'self\' \'unsafe-inline\'; img-src * data:;',
  7 => 'X-Content-Type-Options: nosniff',
  8 => 'X-XSS-Protection: 1; mode=block',
  9 => 'P3P: CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"',
  10 => 'X-Frame-Options: DENY',
  11 => 'Strict-Transport-Security: max-age=31536000',
  12 => 'Location: /?controller=AuthController&action=login',
  13 => 'Content-Length: 0',
  14 => 'Connection: close',
  15 => 'Content-Type: text/html; charset=UTF-8',
  16 => 'HTTP/1.1 200 OK',
  17 => 'Date: Thu, 02 Feb 2017 12:26:52 GMT',
  18 => 'Server: Apache/2.4.10 (Debian)',
  19 => 'Expires: Thu, 19 Nov 1981 08:52:00 GMT',
  20 => 'Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0',
  21 => 'Pragma: no-cache',
  22 => 'Content-Security-Policy: default-src \'self\'; style-src \'self\' \'unsafe-inline\'; img-src * data:;',
  23 => 'X-Content-Type-Options: nosniff',
  24 => 'X-XSS-Protection: 1; mode=block',
  25 => 'P3P: CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"',
  26 => 'X-Frame-Options: DENY',
  27 => 'Strict-Transport-Security: max-age=31536000',
  28 => 'Vary: Accept-Encoding',
  29 => 'Content-Length: 4848',
  30 => 'Connection: close',
  31 => 'Content-Type: text/html; charset=utf-8',
)
==> Response: 
null
in parse:NULL
PHP Fatal error:  Uncaught exception 'JsonRPC\Exception\InvalidJsonFormatException' with message 'Malformed payload' in /home/rca/kanboard-import-trello/vendor/fguillot/json-rpc/src/JsonRPC/Validator/JsonFormatValidator.php:26
Stack trace:
#0 /home/rca/kanboard-import-trello/vendor/fguillot/json-rpc/src/JsonRPC/Response/ResponseParser.php(88): JsonRPC\Validator\JsonFormatValidator::validate(NULL)
#1 /home/rca/kanboard-import-trello/vendor/fguillot/json-rpc/src/JsonRPC/Client.php(204): JsonRPC\Response\ResponseParser->parse()
#2 /home/rca/kanboard-import-trello/vendor/fguillot/json-rpc/src/JsonRPC/Client.php(182): JsonRPC\Client->sendPayload('{"jsonrpc":"2.0...')
#3 /home/rca/kanboard-import-trello/vendor/fguillot/json-rpc/src/JsonRPC/Client.php(126): JsonRPC\Client->execute('getAllProjects', Array)
#4 /home/rca/kanboard-import-trello/import.php(58): JsonRPC\Client->__call('getAllProjects', Array)
#5 /home/rca/kanboard-import-trello/import.php(58): JsonRPC\Client->getAllProjects()
#6 {main}
  thrown in /home/rca/kanboard-import-trello/vendor/fguillot/json-rpc/src/JsonRPC/Validator/JsonFormatValidator.php on line 26

These are examples with curl:

curl -k -d @/tmp/test_request.json -u jsonrpc:token-redacted  https://pm.zhdk.ch/jsonrpc.php
{"jsonrpc":"2.0","result":[{"id":"1","name":"Testprojekt","is_active":"1","token":"","last_modified":"1486031601","is_public":"0","is_private":"0","is_everybody_allowed":"0","default_swimlane":"Default swimlane","show_default_swimlane":"1","description":null,"identifier":"","start_date":"","end_date":"","owner_id":"9","priority_default":"0","priority_start":"0","priority_end":"3","url":{"board":"https:\/\/pm.zhdk.ch\/?controller=BoardViewController&action=show&project_id=1","calendar":"https:\/\/pm.zhdk.ch\/?controller=CalendarController&action=show&project_id=1","list":"https:\/\/pm.zhdk.ch\/?controller=TaskListController&action=show&project_id=1"}}],"id":2134420212}
@daangemist
Copy link
Owner

Looking at the thrown error PHP Fatal error: Uncaught exception 'JsonRPC\Exception\InvalidJsonFormatException' with message 'Malformed payload' in /home/rca/kanboard-import-trello/vendor/fguillot/json-rpc/src/JsonRPC/ValidatorJsonFormatValidator.php:26 it looks to me that the JSON returned by the server you are connecting to is not accepted as valid JSON. Strange that it does work in CURL and not with the library.

Unfortunately I am not actively supporting this library anymore, I made the migration from Trello to Kanboard a while ago and haven't regretted it yet. But if someone is willing to look into this, please do!

@DaffyDuke
Copy link

I've got same problem after disabling SSL certificate verification in vendor/fguillot/json-rpc/src/JsonRPC/HttpClient.php (I know i is a bad idea but I don't know how to bypass it with my SlefSigned certificate

PHP Notice:  date_default_timezone_set(): Timezone ID 'Europe/Paris
' is invalid in /tmp/kanboard-import-trello/util.php on line 31
PHP Fatal error:  Uncaught exception 'JsonRPC\Exception\InvalidJsonFormatException' with message 'Malformed payload' in /tmp/kanboard-import-trello/vendor/fguillot/json-rpc/src/JsonRPC/Validator/JsonFormatValidator.php:26
Stack trace:
#0 /tmp/kanboard-import-trello/vendor/fguillot/json-rpc/src/JsonRPC/Response/ResponseParser.php(86): JsonRPC\Validator\JsonFormatValidator::validate(NULL)
#1 /tmp/kanboard-import-trello/vendor/fguillot/json-rpc/src/JsonRPC/Client.php(194): JsonRPC\Response\ResponseParser->parse()
#2 /tmp/kanboard-import-trello/vendor/fguillot/json-rpc/src/JsonRPC/Client.php(178): JsonRPC\Client->sendPayload('{"jsonrpc":"2.0...')
#3 /tmp/kanboard-import-trello/vendor/fguillot/json-rpc/src/JsonRPC/Client.php(126): JsonRPC\Client->execute('getAllProjects', Array)
#4 /tmp/kanboard-import-trello/import.php(58): JsonRPC\Client->__call('getAllProjects', Array)
#5 /tmp/kanboard-import-trello/import.php(58): JsonRPC\Client->getAllProjects()
#6 {main}
  thrown in /tmp/kanboard-import-trello/vendor/fguillot/json-rpc/src/JsonRPC/Validator/JsonFormatValidator.php on line 26

@psy-q
Copy link
Contributor Author

psy-q commented May 10, 2017

I've written my own import script meanwhile, it can import lists, cards (they become tasks), checklists (they become subtasks of a task) and it tries to assign the correct users by using a mapping that you need to provide if the usernames between Trello and your Kanboard instance don't match.

I couldn't figure out what causes the 'Malformed payload' error, so writing my own was quicker. If anyone is interested, I could clean up the code a bit and put it online? I'm sorry I can't help with the actual issue in this library.

@daangemist
Copy link
Owner

Looking at the first entry of the stacktrace, the response to the request seems to be NULL:

#0 /tmp/kanboard-import-trello/vendor/fguillot/json-rpc/src/JsonRPC/Response/ResponseParser.php(86): JsonRPC\Validator\JsonFormatValidator::validate(NULL)

As I have not implemented the JsonRPC library I do not know what is going on there. Maybe you can report it as an issue at their repository?

@psy-q
Copy link
Contributor Author

psy-q commented May 10, 2017

I've put up my script in the meantime, it's surely not as good as this one, but maybe it helps.

@DaffyDuke
Copy link

Thank you @psy-q , it works !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants