partkeepr / PartKeepr

Open Source Inventory Management
http://www.partkeepr.org
GNU General Public License v3.0
1.34k stars 394 forks source link

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

Open Crazor opened 3 years ago

Crazor commented 3 years ago

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

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 ```
piratehooker69 commented 3 years ago

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.

christianlupus commented 3 years ago

@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?

sibbi77 commented 3 years ago

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.

RChutchev commented 3 years ago

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?

sibbi77 commented 3 years ago

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

RChutchev commented 3 years ago

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