misskey-dev / misskey

🌎 A completely free and open interplanetary microblogging platform 🚀
https://misskey-hub.net/
GNU Affero General Public License v3.0
9.99k stars 1.36k forks source link

TypeError: Cannot read property 'filter' of undefined #7365

Closed cliqsocial closed 2 years ago

cliqsocial commented 3 years ago

💡 Summary

unable to use block this instance TypeError each time trying to toggle the setting

app.12.74.1.js:2 TypeError: Cannot read property 'filter' of undefined
    at Proxy.changeBlock (9814.12.74.1.js:1)
    at kt (app.12.74.1.js:2)
    at Ct (app.12.74.1.js:2)
    at Jt (app.12.74.1.js:2)
    at Proxy.toggle (9814.12.74.1.js:1)
    at 9814.12.74.1.js:1
    at app.12.74.1.js:2
    at kt (app.12.74.1.js:2)
    at Ct (app.12.74.1.js:2)
    at HTMLDivElement.n (app.12.74.1.js:2)

🙂 Expected Behavior

no error message

☚ī¸ Actual Behavior

error when toggle block this instance

📝 Steps to Reproduce

  1. as admin go to /instance/federation
  2. choose instance
  3. toggle block this instance = error

📌 Environment

misskey 12.74.1 - node 12.21.0 - postgresql v10.16

Johann150 commented 3 years ago

Also: The block switch does not correctly show if the instance is blocked, if this is set separately in the Instance Settings under "Blocked Instances".

I think the issue is that this.meta.blockedHosts is undefined:

https://github.com/misskey-dev/misskey/blob/7e30910ab84e1bec6779b5d4b89db02274768b18/src/client/pages/instance/instance.vue#L210-L212 https://github.com/misskey-dev/misskey/blob/7e30910ab84e1bec6779b5d4b89db02274768b18/src/client/pages/instance/instance.vue#L255-L259

If this.meta.blockedHosts is undefined, line 211 will always result in false. So the second alternative of the ternary expression on line 257 will always be used, which causes the original error message Cannot read property 'filter' of undefined.

I think this.meta.blockedHosts would be available if the api/meta request would contain detail: true, which is not the case. I am not sure how that could be done.

cliqsocial commented 2 years ago

Still not working. Tested with misskey 12.96.1

app.12.96.1.js:2 TypeError: Cannot read properties of undefined (reading 'filter')
    at Proxy.changeBlock (7317.12.96.1.js:1)
    at wn (app.12.96.1.js:2)
    at _n (app.12.96.1.js:2)
    at c (app.12.96.1.js:2)
    at Proxy.toggle (7317.12.96.1.js:1)
    at 7317.12.96.1.js:1
    at app.12.96.1.js:2
    at wn (app.12.96.1.js:2)
    at _n (app.12.96.1.js:2)
    at HTMLDivElement.n (app.12.96.1.js:2)
(anonymous) @ app.12.96.1.js:2
Mai-Lapyst commented 2 years ago

Same error here with misskey 12.98.0. But now it's displaying the underlaying error directly:

TypeError: this.meta.blockedHosts is undefined app.12.98.0.js:2:130977
    changeBlock 7317.12.98.0.js:1
    wn app.12.98.0.js:2
    _n app.12.98.0.js:2
    c app.12.98.0.js:2
    toggle 9847.12.98.0.js:1
    62165/f</a[1]< 9847.12.98.0.js:1
    me app.12.98.0.js:2
    wn app.12.98.0.js:2
    _n app.12.98.0.js:2
    n app.12.98.0.js:2
    xn app.12.98.0.js:2
    xn app.12.98.0.js:2
    wn app.12.98.0.js:2
    _n app.12.98.0.js:2
    c app.12.98.0.js:2
    toggle 9847.12.98.0.js:1
    62165/f</a[1]< 9847.12.98.0.js:1
    me app.12.98.0.js:2
    wn app.12.98.0.js:2
    _n app.12.98.0.js:2
    n app.12.98.0.js:2
Mai-Lapyst commented 2 years ago

I think I found the source of this bug: https://github.com/misskey-dev/misskey/blob/0e4a111f81cceed275d9bec2695f6e401fb654d8/packages/client/src/instance.ts#L15-L25

When I tweak firefox to use true for detail here instead of false the block button for an instance now works as intended.

Johann150 commented 2 years ago

The solution given by Mai-Lapyst does not work any more because the blockedHosts data is only available from the /api/admin/meta endpoint since the refactoring in d0a346ed8ab3fd879d0e1d2635df0b77a9b0bc05.