PartKeepr icon indicating copy to clipboard operation
PartKeepr copied to clipboard

Adding part data from OctoPart yields "Uncaught TypeError: this.data.specs[i].metadata is undefined"

Open Crazor opened this issue 4 years ago • 6 comments

Bug description

Part parameters cannot be applied from Octopart results.

Steps to reproduce

  1. Add or edit a part
  2. Click on 'Octopart...'
  3. Select result
  4. Click 'Add Data'

Expected behavior

I expect the part data to update

Observed behavior

Nothing happens in the UI and the following error is printed to the console:

Uncaught TypeError: this.data.specs[i].metadata is undefined

System Information

  • PartKeepr Version: current master (41e1c41)
  • Operating System: Linux
  • Web Server: apache
  • PHP Version: 7.1
  • Database and version: MariaDB 10.0
  • Reproducible on the demo system: No (because OctoPart API access doesn't work there currently, "No app for token 525ccf58 not found")

JavaScript errors

JavaScript logs
XHR GEThttp://localhost:8080/api/octopart/get/1412597?_dc=1610534645257
[HTTP/1.1 200 OK 346ms]

Uncaught TypeError: this.data.specs[i].metadata is undefined
    checkRequirements http://localhost:8080/js/compiled/main2.js:30391
    applyData http://localhost:8080/js/compiled/main2.js:30619
    onPartDataLoaded http://localhost:8080/js/compiled/main2.js:30360
    callback http://localhost:8080/js/compiled/extjs.js:22
    onComplete http://localhost:8080/js/compiled/extjs.js:22
    onStateChange http://localhost:8080/js/compiled/extjs.js:22
    bind http://localhost:8080/js/compiled/extjs.js:22
    start http://localhost:8080/js/compiled/extjs.js:22
    request http://localhost:8080/js/compiled/extjs.js:22
    loadData http://localhost:8080/js/compiled/main2.js:30345
    applyData http://localhost:8080/js/compiled/main2.js:30264
    onAddClick http://localhost:8080/js/compiled/main2.js:30236
    callback http://localhost:8080/js/compiled/extjs.js:22
    fireHandler http://localhost:8080/js/compiled/extjs.js:22
    onClick http://localhost:8080/js/compiled/extjs.js:22
    fire http://localhost:8080/js/compiled/extjs.js:22
    fire http://localhost:8080/js/compiled/extjs.js:22
    publish http://localhost:8080/js/compiled/extjs.js:22
    publishDelegatedDomEvent http://localhost:8080/js/compiled/extjs.js:22
    doDelegatedEvent http://localhost:8080/js/compiled/extjs.js:22
    onDelegatedEvent http://localhost:8080/js/compiled/extjs.js:22
    bind http://localhost:8080/js/compiled/extjs.js:22

Crazor avatar Jan 13 '21 10:01 Crazor

I had a similar problem, it was related to the built in tracker/script/cookie blocking in Brave. Switching off Brave's "shields up/down" switch resolved it. Your browser or a plugin may be doing the same.

piratehooker69 avatar Jan 28 '21 05:01 piratehooker69

@sibbi77 you did the latest changes in the Octopart section of the code. As far as I understand it, the requests towards OctoPart are triggered in the PHP server. So the browser's settings should not have any effect in theory. Can you confirm this interpretation?

Do you have a clue what the problem might be?

christianlupus avatar Feb 05 '21 17:02 christianlupus

I'll have a look at the code. If I remember correctly, one user had a different account type at Octopart and had problems with it. The "Pro Free" account has all features and is free. Other account types may deliver fewer data fields or not return data at all (because of a request tailored to the "Pro Free" account. I'm not sure about that.

sibbi77 avatar Feb 05 '21 19:02 sibbi77

Hello, i've same problem. Logs: main2.js:30391 Uncaught TypeError: Cannot read property 'unit' of undefined at g.checkRequirements (main2.js:30391) at g.applyData (main2.js:30619) at g.onPartDataLoaded (main2.js:30360) at Object.callback (extjs.js:22) at F.onComplete (extjs.js:22) at F.onStateChange (extjs.js:22) at XMLHttpRequest.t (extjs.js:22)

CAD option is disabled and account is PRO Free image

OctoParts returns data image specs image but response not contain metadata (and unit obviously) image

datasheets also isn't working image this.data.datasheets = undefined

this.data.compliance_documents - same imagesets - same this.data.offers (distributors) - same

Only Manufacturer is working fine image

@sibbi77 can u help with this issue?

RChutchev avatar Jun 04 '21 18:06 RChutchev

You are not using the latest code; compare to https://github.com/partkeepr/PartKeepr/blob/c6323d57ddc8e7a13d29d2a7a111d7ac2b1dfa40/src/PartKeepr/FrontendBundle/Resources/public/js/Components/OctoPart/DataApplicator.js#L81

sibbi77 avatar Jun 04 '21 20:06 sibbi77

You are not using the latest code; compare to

https://github.com/partkeepr/PartKeepr/blob/c6323d57ddc8e7a13d29d2a7a111d7ac2b1dfa40/src/PartKeepr/FrontendBundle/Resources/public/js/Components/OctoPart/DataApplicator.js#L81

Yes, it helped me a lot, thank you! image

RChutchev avatar Jun 05 '21 18:06 RChutchev