joplin icon indicating copy to clipboard operation
joplin copied to clipboard

Uploading image via data API in profile broken

Open marph91 opened this issue 1 year ago • 4 comments

Operating system

Linux

Joplin version

2.14.17

Desktop version info

Joplin 2.14.17 (prod, linux)

Client-ID: 1721bfa3c057445da06c21164e8c2a6a Sync-Version: 3 Profil-Version: 46 Unterstützter Schlüsselbund: Nein

Revision: 094175c

Backup: 1.4.0

Current behaviour

  1. Download appimage for Joplin 2.14.17
  2. Start Joplin with profile. For example: ./joplin.AppImage --profile some_profile
  3. Enable webclipper
  4. Execute the example code for attaching an image
$ curl --data '{ "title": "Image test", "body": "Here is Joplin icon:", "image_data_url": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAIAAABLbSncAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAANZJREFUeNoAyAA3/wFwtO3K6gUB/vz2+Prw9fj/+/r+/wBZKAAExOgF4/MC9ff+MRH6Ui4E+/0Bqc/zutj6AgT+/Pz7+vv7++nu82c4DlMqCvLs8goA/gL8/fz09fb59vXa6vzZ6vjT5fbn6voD/fwC8vX4UiT9Zi//APHyAP8ACgUBAPv5APz7BPj2+DIaC2o3E+3o6ywaC5fT6gD6/QD9/QEVf9kD+/dcLQgJA/7v8vqfwOf18wA1IAIEVycAyt//v9XvAPv7APz8LhoIAPz9Ri4OAgwARgx4W/6fVeEAAAAASUVORK5CYII="}' http://127.0.0.1:41184/notes?token=4257679f216ca66bb9055b699529f3fb9a2812dc9e5576b62347a69012a80de4b297dff04841f36c8ee87653a7e33c63815d99fab749956d6aacc8c6218e5ef2
{"error":"Internal Server Error: Cannot create property 'httpCode' on string 'Image at some_profile/tmp/b5e1ab15cd1ab971eded6e3d235e0527.png failed to load.': \n\nTypeError: Cannot create property 'httpCode' on string 'Image at some_profile/tmp/b5e1ab15cd1ab971eded6e3d235e0527.png failed to load.'\n    at Api.<anonymous> (/tmp/.mount_joplinojcqOq/resources/app.asar/node_modules/@joplin/lib/services/rest/Api.js:162:36)\n    at Generator.throw (<anonymous>)\n    at rejected (/tmp/.mount_joplinojcqOq/resources/app.asar/node_modules/@joplin/lib/services/rest/Api.js:6:65)"}

Expected behaviour

The image should be attached successfully.

Side notes:

  • It works when using the default profile.
  • It worked with Joplin 2.13.9. It was tested here

Logs

No response

marph91 avatar Mar 03 '24 10:03 marph91

I haven't managed to reproduce this.

These are the tests I've done (replacing <<token_here>> with Joplin's Webclipper access token):

  • yarn start -- default profile/dev mode.
    $ curl --data '{ "title": "Image test", "body": "Here is Joplin icon:", "image_data_url": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAIAAABLbSncAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAANZJREFUeNoAyAA3/wFwtO3K6gUB/vz2+Prw9fj/+/r+/wBZKAAExOgF4/MC9ff+MRH6Ui4E+/0Bqc/zutj6AgT+/Pz7+vv7++nu82c4DlMqCvLs8goA/gL8/fz09fb59vXa6vzZ6vjT5fbn6voD/fwC8vX4UiT9Zi//APHyAP8ACgUBAPv5APz7BPj2+DIaC2o3E+3o6ywaC5fT6gD6/QD9/QEVf9kD+/dcLQgJA/7v8vqfwOf18wA1IAIEVycAyt//v9XvAPv7APz8LhoIAPz9Ri4OAgwARgx4W/6fVeEAAAAASUVORK5CYII="}' 'http://127.0.0.1:27583/notes?token=<<token_here>>'
    
  • yarn start -- secondary profile/dev mode.
    $ curl --data '{ "title": "Image test", "body": "Here is Joplin icon:", "image_data_url": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAIAAABLbSncAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAANZJREFUeNoAyAA3/wFwtO3K6gUB/vz2+Prw9fj/+/r+/wBZKAAExOgF4/MC9ff+MRH6Ui4E+/0Bqc/zutj6AgT+/Pz7+vv7++nu82c4DlMqCvLs8goA/gL8/fz09fb59vXa6vzZ6vjT5fbn6voD/fwC8vX4UiT9Zi//APHyAP8ACgUBAPv5APz7BPj2+DIaC2o3E+3o6ywaC5fT6gD6/QD9/QEVf9kD+/dcLQgJA/7v8vqfwOf18wA1IAIEVycAyt//v9XvAPv7APz8LhoIAPz9Ri4OAgwARgx4W/6fVeEAAAAASUVORK5CYII="}' 'http://127.0.0.1:27583/notes?token=<<token_here>>'
    
  • npx electron . --profile /tmp/foo2 -- using the --profile flag, release mode.
    $ curl --data '{ "title": "Image test", "body": "Here is Joplin icon:", "image_data_url": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAIAAABLbSncAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAANZJREFUeNoAyAA3/wFwtO3K6gUB/vz2+Prw9fj/+/r+/wBZKAAExOgF4/MC9ff+MRH6Ui4E+/0Bqc/zutj6AgT+/Pz7+vv7++nu82c4DlMqCvLs8goA/gL8/fz09fb59vXa6vzZ6vjT5fbn6voD/fwC8vX4UiT9Zi//APHyAP8ACgUBAPv5APz7BPj2+DIaC2o3E+3o6ywaC5fT6gD6/QD9/QEVf9kD+/dcLQgJA/7v8vqfwOf18wA1IAIEVycAyt//v9XvAPv7APz8LhoIAPz9Ri4OAgwARgx4W/6fVeEAAAAASUVORK5CYII="}' 'http://127.0.0.1:41184/notes?token=<<token_here>>'
    
  • ./Joplin-2.14.20.AppImage --profile /tmp/test3 -- using the --profile flag, release mode
    $ curl --data '{ "title": "Image test", "body": "Here is Joplin icon:", "image_data_url": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAIAAABLbSncAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAANZJREFUeNoAyAA3/wFwtO3K6gUB/vz2+Prw9fj/+/r+/wBZKAAExOgF4/MC9ff+MRH6Ui4E+/0Bqc/zutj6AgT+/Pz7+vv7++nu82c4DlMqCvLs8goA/gL8/fz09fb59vXa6vzZ6vjT5fbn6voD/fwC8vX4UiT9Zi//APHyAP8ACgUBAPv5APz7BPj2+DIaC2o3E+3o6ywaC5fT6gD6/QD9/QEVf9kD+/dcLQgJA/7v8vqfwOf18wA1IAIEVycAyt//v9XvAPv7APz8LhoIAPz9Ri4OAgwARgx4W/6fVeEAAAAASUVORK5CYII="}' 'http://127.0.0.1:41184/notes?token=<<token_here>>'
    
    {"title":"Image test","body":"Here is Joplin icon:\n\n![22e66a47cf1a1e232e637c106e6ffa8e.png](:/2433b11b14c14843b1af3692598bf2f4)\n\n","parent_id":"02f65ba32f7b42f0ab25e98bcf8ff0c7","markup_language":1,"updated_time":1713891193164,"created_time":1713891193055,"user_updated_time":1713891193164,"user_created_time":1713891193055,"source":"joplin-desktop","source_application":"net.cozic.joplin-desktop","order":1713891193055,"id":"7afbf92990ec4cefb7b796ad3b495326","type_":1}
    

I've only included the output from the last call to curl.

I'm testing on Ubuntu 23.10. The dev-mode tests are from 15770e92988c7bd02fed60066da160cad3de331b.

I can reproduce this if I pass a relative path to --profile.

Additionally, if I do this, most of the welcome notes aren't created (nor are they rendered properly): screenshot: Welcome notes rendered in a serif font

Note that the --profile flag is not officially supported.

Thanks for investigating!

Note that the --profile flag is not officially supported.

Is there still a chance this gets fixed? Or should I do the workaround of specifying absolute paths?

marph91 avatar Apr 24 '24 19:04 marph91

Is there still a chance this gets fixed? Or should I do the workaround of specifying absolute paths?

For now, I would suggest using absolute paths.

For reference, however, the content of the profile flag is loaded from argv here: https://github.com/laurent22/joplin/blob/aac8d583729e796c23366972f8dcf71480df01ce/packages/lib/utils/processStartFlags.ts#L31