Skip to content

Textfilter reload on invalid#1381

Closed
priya-tik wants to merge 1 commit into
opencast:r/18.xfrom
priya-tik:textfilter-reload-on-invalid
Closed

Textfilter reload on invalid#1381
priya-tik wants to merge 1 commit into
opencast:r/18.xfrom
priya-tik:textfilter-reload-on-invalid

Conversation

@priya-tik

Copy link
Copy Markdown
Contributor

This PR adds a guard in the getTextFilter selector to safely handle cases where textFilter is not an array. This prevents the following runtime error from crashing the app

@github-actions

Copy link
Copy Markdown
Contributor

Use docker or podman to test this pull request locally.

Run test server using develop.opencast.org as backend:

podman run --rm -it -p 127.0.0.1:3000:3000 ghcr.io/opencast/opencast-admin-interface:pr-1381

Specify a different backend like stable.opencast.org:

podman run --rm -it -p 127.0.0.1:3000:3000 -e PROXY_TARGET=https://stable.opencast.org ghcr.io/opencast/opencast-admin-interface:pr-1381

It may take a few seconds for the interface to spin up.
It will then be available at http://127.0.0.1:3000.
For more options you can pass on to the proxy, take a look at the README.md.

@Arnei

Arnei commented Jul 29, 2025

Copy link
Copy Markdown
Member

I have my reservations against this. First of all, if we want to ensure that textFilter can only ever be an array, a selector is not the place for that. The reducers should take care of that. Secondly, I don't want to add a catch block that deletes local storage everytime we change the type of a variable in local storage to every selector (and potentially other places) that use that variable.

@priya-tik

Copy link
Copy Markdown
Contributor Author

Thanks. You're right that selectors should stay pure and not cause side effects like clearing storage or triggering reloads. I added the check to prevent the crash users are seeing, but I agree it's better to fix this earlier, either in the reducer when loading state, or with app versioning logic. I'll move the validation out of the selector and update the PR. Thanks for the feedback

@lkiesow lkiesow added the type:bug Something isn't working label Aug 28, 2025
@lkiesow

lkiesow commented Aug 28, 2025

Copy link
Copy Markdown
Member

I'd like to apply the “Be pragmatic” rule to #1395 or this pull request. I understand that it is annoying to deal with changed data structures in the browser's local storage, but the reality is that we have to if we don't want users to end up with a completely broken interface. I got contacted a bunch of times about develop.opencast.org being broken. Usually by technical people. They couldn't fix that locally (they didn't realize that they had to drop their in-browser storage) and just assumed Opencast was down.

I'm also fine with working out a more generic solution for this, like dropping the local storage automatically if users run into an exception. But we can't just reject valid solutions for the problem at hand just because there might be a better one. That's something for later. Opencast is kind of broken for users now.

Can we merge one patch and bring it in today's release?

@mtneug

mtneug commented Aug 28, 2025

Copy link
Copy Markdown
Member

IMO it's a better solution to clear the local storage automatically if there is data in an unexpected format. I'm would therefore prefer to merge this PR instead of #1395.

I'm fine with this going into today's release. I created #1414 to track the "better solution".

@lkiesow lkiesow changed the base branch from develop to r/18.x August 28, 2025 10:25
@lkiesow

lkiesow commented Aug 28, 2025

Copy link
Copy Markdown
Member

I agreed and started testing this patch. Now I recommend we merge the other patch after all. This patch causes the UI to end up in an endless reload loop:

admin-interface-endless-loop.mp4

lkiesow added a commit to lkiesow/opencast-admin-interface that referenced this pull request Aug 28, 2025
Investigating people complaining develop.opencast.org being broken, it
seems like there was a change to the filters which cannot handle the
previous data which might still be stored in browsers. Like here means,
it completely crashes the interface and users just see a blank page.

The error they get is:

```
Uncaught TypeError: t.find is not a function
    fk tableFilterSelectors.ts:23
    D reselect.mjs:647
    i reselect.mjs:584
    P reselect.mjs:659
    i reselect.mjs:584
    u TableFilters.tsx:55
    <anonymous> Redux
    L use-sync-external-store-with-selector.production.js:40
    h use-sync-external-store-with-selector.production.js:63
    React 2
    useSyncExternalStoreWithSelector use-sync-external-store-with-selector.production.js:74
    n Redux
    qc TableFilters.tsx:55
    React 14
    K scheduler.production.js:152
tableFilterSelectors.ts:23:32
```

This patch introduces a general validation for filters, resetting them
if they are corrupted in the sense that the data structure is not
correct.

This closes opencast#1381
This closes opencast#1395
lkiesow added a commit to lkiesow/opencast-admin-interface that referenced this pull request Aug 28, 2025
Investigating people complaining develop.opencast.org being broken, it
seems like there was a change to the filters which cannot handle the
previous data which might still be stored in browsers. Like here means,
it completely crashes the interface and users just see a blank page.

The error they get is:

```
Uncaught TypeError: t.find is not a function
    fk tableFilterSelectors.ts:23
    D reselect.mjs:647
    i reselect.mjs:584
    P reselect.mjs:659
    i reselect.mjs:584
    u TableFilters.tsx:55
    <anonymous> Redux
    L use-sync-external-store-with-selector.production.js:40
    h use-sync-external-store-with-selector.production.js:63
    React 2
    useSyncExternalStoreWithSelector use-sync-external-store-with-selector.production.js:74
    n Redux
    qc TableFilters.tsx:55
    React 14
    K scheduler.production.js:152
tableFilterSelectors.ts:23:32
```

This patch introduces a general validation for filters, resetting them
if they are corrupted in the sense that the data structure is not
correct.

This closes opencast#1381
This closes opencast#1395
@gregorydlogan

Copy link
Copy Markdown
Member

We went with yet another alternative in #1418

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type:bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants