frontend: guard against null disabledProducts in Footer#1963
Conversation
When the disabled-products API call errors, useAction returns
`{ data: null }`, which then propagated into state and caused
"right-hand side of 'in' should be an object, got null" at render
time. Default to an empty object so the `in` check stays valid.
This can happen e.g. on localdev if the self-signed cert for the public
endpoint is rejected by the browser.
| export default function Footer() { | ||
| const location = useLocation(); | ||
| const group = new URLSearchParams(location.search).get('group') || 'firefox'; | ||
| const [disabledProducts, setDisabledProducts] = useState([]); |
There was a problem hiding this comment.
Somewhat unrelated but might be worth a follow up to set that to {} by default. I think it's not creating any issue because the only use is product.product in disabledProducts && disabledProducts[product.product].includes(pb.branch) and it behaves the same (and thus gets short circuited):
> "a" in []
false
> "a" in {}
false
|
As a side note we may want some explicit message/marker in the UI when access to the public api doesn't work, like we have for admin. Before this patch it's a js type error, after this patch the footer with the automated releases status is just silently broken. |
|
Yeah, should be fairly easy, just dupe the Lines 95 to 127 in aff6975 Can probably factor a bit, and skip |
When the disabled-products API call errors, useAction returns
{ data: null }, which then propagated into state and caused "right-hand side of 'in' should be an object, got null" at render time. Default to an empty object so theincheck stays valid.This can happen e.g. on localdev if the self-signed cert for the public endpoint is rejected by the browser.