kanasimi / wikiapi

JavaScript MediaWiki API for node.js
https://kanasimi.github.io/wikiapi/
BSD 3-Clause "New" or "Revised" License
47 stars 5 forks source link

`TypeError: item.includes is not a function` when uploading. #29

Closed hugolpz closed 3 years ago

hugolpz commented 3 years ago

Following up for yesterday upload issue. Down the road I now meet this :

$ node ./create-Commons-upload.js
Connecting...
get_API_parameters: Set enwiki: path=query+siteinfo                    # <------- Side issue: why talk about enwiki ? My target is Commons.
get_API_parameters: Set commonswiki: path=query+siteinfo
Username ShufaBot@ShufaBot is connected !
wiki_API_page: Not exists: [[:File:A-red.png]]                         # <------- this is good, I want to upload when page is empty
get_API_parameters: Set commonswiki: path=upload
/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:553
            : !item.includes(boundary);
                    ^

TypeError: item.includes is not a function                              # <------- This is the rocks on the road ! 
    at not_includes_in (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:553:12)
    at Array.every (<anonymous>)
    at not_includes_in (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:551:38)
    at Array.every (<anonymous>)
    at not_includes_in (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:551:38)
    at give_boundary (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:570:9)
    at process_next (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:712:5)
    at process_next (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:790:4)
    at push_and_callback (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:630:5)
    at get_file_object (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:661:5)
kanasimi commented 3 years ago

When we can not read, it will throw now.

hugolpz commented 3 years ago

Still fails on my side. I did npm update. Need to publish the fix or else ?

kanasimi commented 3 years ago

I make a debug version. May you update to the latest version, and un-comment https://github.com/kanasimi/CeJS/commit/25432fa0e026a0a02a671d19f4dd99a39fdc81d2#diff-678626254263abe7a9e4f91dab2070aa8f24508bf2f96a31acf9d9b5ef8316b4R553 to see what item is?

hugolpz commented 3 years ago

I'm not very fluent in NodeJS so I didn't understand your previous messages. Please give me slower-clearer guidance on this issue.

May you update to the latest version ?

$npm update says I'am already up to date. Last npm publication was 4 days ago.

$ npm v cejs
cejs@4.1.14 | BSD-3-Clause | deps: none | versions: 118
...
latest: 4.1.14 
published 4 days ago by vimunci <vimunci@gmail.com>
$ npm v wikiapi
wikiapi@1.14.1 | BSD-3-Clause | deps: 1 | versions: 24
...
latest: 1.14.1  
published a month ago by vimunci <vimunci@gmail.com>

Download Ajax.js

So I downloaded Ajax.js. (I'am not sure it is enough). The terminal output is then:

$ node ./create-Commons-upload.js
get_API_parameters: Set commonswiki: path=query+siteinfo
Username ShufaBot@ShufaBot is connected !
get_API_parameters: Set commonswiki: path=upload
Trace: [
  'object',
  [
    [
      'Content-Disposition: form-data; name="comment"\r\n' +
        'Content-Type: text/plain; charset=UTF-8\r\n' +
        '\r\n',
      <Buffer 55 70 6c 6f 61 64 20 72 65 64 20 73 74 72 6f 6b 65 20 6f 72 64 65 72 20 66 6f 72 20 43 68 69 6e 65 73 65 20 63 68 61 72 61 63 74 65 72 20 61 2e>,
      content_length: 139
    ],
    [
      'Content-Disposition: form-data; name="text"\r\n' +
        'Content-Type: text/plain; charset=UTF-8\r\n' +
        '\r\n',
      <Buffer 7b 7b 53 4f 6c 69 63 65 6e 73 65 7c 61 7c 7c 72 65 64 2e 70 6e 67 7c 7c 74 72 75 65 2c 66 61 6c 73 65 2c 66 61 6c 73 65 2c 66 61 6c 73 65 2c 66 61 6c ... 92 more bytes>,
      content_length: 230
    ],
    [
      'Content-Disposition: form-data; name="ignorewarnings"\r\n\r\n',
      true,
      content_length: NaN
    ],
    [
      'Content-Disposition: form-data; name="token"\r\n' +
        'Content-Type: text/plain; charset=UTF-8\r\n' +
        '\r\n',
      <Buffer 34 63 37 33 66 32 61 35 32 37 39 38 66 61 32 39 33 31 30 63 38 64 64 37 61 37 62 35 35 37 65 63 36 30 36 61 61 62 30 37 2b 5c>,
      content_length: 131
    ],
    [
      `Content-Disposition: form-data; name="file"; filename="a-red.png"; filename*=UTF-8''a-red.png\r\n` +
        'Content-Type: image/png\r\n' +
        'Content-Transfer-Encoding: binary\r\n' +
        '\r\n',
      <Buffer 89 50 4e 47 0d 0a 1a 0a 00 00 00 0d 49 48 44 52 00 00 01 2c 00 00 01 2c 08 03 00 00 00 4e a3 7e 47 00 00 00 04 67 41 4d 41 00 00 b1 8f 0b fc 61 05 00 ... 2664 more bytes>,
      content_length: 2871
    ],
    [
      'Content-Disposition: form-data; name="filename"\r\n' +
        'Content-Type: text/plain; charset=UTF-8\r\n' +
        '\r\n',
      <Buffer 61 2d 72 65 64 2e 70 6e 67>,
      content_length: 101
    ],
    to_Array: [Function: form_data_to_Array]
  ]
]
    at not_includes_in (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:553:12)
    at give_boundary (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:573:9)
    at process_next (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:716:5)
    at process_next (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:794:4)
    at push_and_callback (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:633:5)
    at get_file_object (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:665:5)
    at process_next (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:762:5)
    at process_next (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:794:4)
    at process_next (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:794:4)
    at process_next (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:794:4)
Trace: [
  'object',
  [
    'Content-Disposition: form-data; name="comment"\r\n' +
      'Content-Type: text/plain; charset=UTF-8\r\n' +
      '\r\n',
    <Buffer 55 70 6c 6f 61 64 20 72 65 64 20 73 74 72 6f 6b 65 20 6f 72 64 65 72 20 66 6f 72 20 43 68 69 6e 65 73 65 20 63 68 61 72 61 63 74 65 72 20 61 2e>,
    content_length: 139
  ]
]
    at not_includes_in (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:553:12)
    at Array.every (<anonymous>)
    at not_includes_in (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:554:38)
    at give_boundary (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:573:9)
    at process_next (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:716:5)
    at process_next (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:794:4)
    at push_and_callback (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:633:5)
    at get_file_object (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:665:5)
    at process_next (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:762:5)
    at process_next (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:794:4)
Trace: [
  'string',
  'Content-Disposition: form-data; name="comment"\r\n' +
    'Content-Type: text/plain; charset=UTF-8\r\n' +
    '\r\n'
]
    at not_includes_in (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:553:12)
    at Array.every (<anonymous>)
    at not_includes_in (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:554:38)
    at Array.every (<anonymous>)
    at not_includes_in (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:554:38)
    at give_boundary (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:573:9)
    at process_next (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:716:5)
    at process_next (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:794:4)
    at push_and_callback (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:633:5)
    at get_file_object (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:665:5)
Trace: [
  'object',
  <Buffer 55 70 6c 6f 61 64 20 72 65 64 20 73 74 72 6f 6b 65 20 6f 72 64 65 72 20 66 6f 72 20 43 68 69 6e 65 73 65 20 63 68 61 72 61 63 74 65 72 20 61 2e>
]
    at not_includes_in (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:553:12)
    at Array.every (<anonymous>)
    at not_includes_in (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:554:38)
    at Array.every (<anonymous>)
    at not_includes_in (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:554:38)
    at give_boundary (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:573:9)
    at process_next (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:716:5)
    at process_next (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:794:4)
    at push_and_callback (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:633:5)
    at get_file_object (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:665:5)
Trace: [
  'object',
  [
    'Content-Disposition: form-data; name="text"\r\n' +
      'Content-Type: text/plain; charset=UTF-8\r\n' +
      '\r\n',
    <Buffer 7b 7b 53 4f 6c 69 63 65 6e 73 65 7c 61 7c 7c 72 65 64 2e 70 6e 67 7c 7c 74 72 75 65 2c 66 61 6c 73 65 2c 66 61 6c 73 65 2c 66 61 6c 73 65 2c 66 61 6c ... 92 more bytes>,
    content_length: 230
  ]
]
    at not_includes_in (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:553:12)
    at Array.every (<anonymous>)
    at not_includes_in (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:554:38)
    at give_boundary (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:573:9)
    at process_next (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:716:5)
    at process_next (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:794:4)
    at push_and_callback (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:633:5)
    at get_file_object (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:665:5)
    at process_next (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:762:5)
    at process_next (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:794:4)
Trace: [
  'string',
  'Content-Disposition: form-data; name="text"\r\n' +
    'Content-Type: text/plain; charset=UTF-8\r\n' +
    '\r\n'
]
    at not_includes_in (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:553:12)
    at Array.every (<anonymous>)
    at not_includes_in (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:554:38)
    at Array.every (<anonymous>)
    at not_includes_in (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:554:38)
    at give_boundary (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:573:9)
    at process_next (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:716:5)
    at process_next (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:794:4)
    at push_and_callback (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:633:5)
    at get_file_object (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:665:5)
Trace: [
  'object',
  <Buffer 7b 7b 53 4f 6c 69 63 65 6e 73 65 7c 61 7c 7c 72 65 64 2e 70 6e 67 7c 7c 74 72 75 65 2c 66 61 6c 73 65 2c 66 61 6c 73 65 2c 66 61 6c 73 65 2c 66 61 6c ... 92 more bytes>
]
    at not_includes_in (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:553:12)
    at Array.every (<anonymous>)
    at not_includes_in (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:554:38)
    at Array.every (<anonymous>)
    at not_includes_in (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:554:38)
    at give_boundary (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:573:9)
    at process_next (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:716:5)
    at process_next (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:794:4)
    at push_and_callback (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:633:5)
    at get_file_object (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:665:5)
Trace: [
  'object',
  [
    'Content-Disposition: form-data; name="ignorewarnings"\r\n\r\n',
    true,
    content_length: NaN
  ]
]
    at not_includes_in (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:553:12)
    at Array.every (<anonymous>)
    at not_includes_in (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:554:38)
    at give_boundary (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:573:9)
    at process_next (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:716:5)
    at process_next (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:794:4)
    at push_and_callback (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:633:5)
    at get_file_object (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:665:5)
    at process_next (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:762:5)
    at process_next (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:794:4)
Trace: [
  'string',
  'Content-Disposition: form-data; name="ignorewarnings"\r\n\r\n'
]
    at not_includes_in (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:553:12)
    at Array.every (<anonymous>)
    at not_includes_in (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:554:38)
    at Array.every (<anonymous>)
    at not_includes_in (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:554:38)
    at give_boundary (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:573:9)
    at process_next (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:716:5)
    at process_next (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:794:4)
    at push_and_callback (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:633:5)
    at get_file_object (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:665:5)
Trace: [ 'boolean', true ]
    at not_includes_in (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:553:12)
    at Array.every (<anonymous>)
    at not_includes_in (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:554:38)
    at Array.every (<anonymous>)
    at not_includes_in (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:554:38)
    at give_boundary (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:573:9)
    at process_next (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:716:5)
    at process_next (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:794:4)
    at push_and_callback (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:633:5)
    at get_file_object (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:665:5)
/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:556
            : !item.includes(boundary);
                    ^

TypeError: item.includes is not a function
    at not_includes_in (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:556:12)
    at Array.every (<anonymous>)
    at not_includes_in (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:554:38)
    at Array.every (<anonymous>)
    at not_includes_in (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:554:38)
    at give_boundary (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:573:9)
    at process_next (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:716:5)
    at process_next (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:794:4)
    at push_and_callback (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:633:5)
    at get_file_object (/home/yug/Documents/DragonsBot/node_modules/cejs/application/net/Ajax.js:665:5)
hugolpz commented 3 years ago

@kanasimi I changed ignorewarnings: true into ignorewarnings: 1 and it works again. 🤦🏼 😭

kanasimi commented 3 years ago

It should works now even you using ignorewarnings: true.