Skip to content

Bug fixes issue #10 #71

Open
ututono wants to merge 18 commits intodevfrom
fix-10-bug_fixes
Open

Bug fixes issue #10 #71
ututono wants to merge 18 commits intodevfrom
fix-10-bug_fixes

Conversation

@ututono
Copy link
Collaborator

@ututono ututono commented Jan 27, 2026

Goal: This patch aims to resolve the issue #10, addressing multiple bugs related to document validation. The main focus is on providing a better user experience when documents are missing, deleted, or inaccessible.

Key Changes:

  1. Added a new validateDocument() method in backend/webserver/sockets/document.js that centralizes document validation logic:

    • Checks for: database record existence, user access permissions, and file existence on disk
    • Returns structured error codes (DOCUMENT_NOT_FOUND, ACCESS_DENIED, FILE_MISSING), details are in the comment [BUG] Error when document is not loaded #10 (comment), for consistent error handling
  2. Improved UX - Error Pages Instead of Toasts. Replaced toast notifications with more informative error pages when documents are unavailable. Implemented in both Document.vue and Study.vue components.

  3. Loading Modal Fixes. Fixed issue where the loading modal would freeze when encountering document errors. The result why close() can not correctly terminate the loading modal seems to be hide() deferred when isShown=false, but component unmounts before deferred hide runs in frontend/src/basic/Modal.vue. Modal now properly closes and emits error events when a document cannot be loaded by replacing hide() with dispose() in beforeunmount().

  4. Error messages are now consistent whether a file was deleted through the UI or is missing from the file system.

Demonstration:
Test accessing shared links to the document which has been deleted from the UI interface and from the filesystem accordingly.

Test accessing shared links to the study which uses a document which has been deleted from the UI interface and from the filesystem accordingly.

@ututono ututono self-assigned this Jan 27, 2026
@ututono ututono linked an issue Jan 27, 2026 that may be closed by this pull request
3 tasks
@ututono
Copy link
Collaborator Author

ututono commented Feb 11, 2026

@dennis-zyska I’ve addressed your requested changes and pushed an updated commit 5216562. Could you please take another look?

@NilsDy FYI

@ututono ututono requested a review from dennis-zyska February 11, 2026 14:20
Copy link
Collaborator

@dennis-zyska dennis-zyska left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The solution with the text parsing with the error codes should be improved. We can change the function here: https://github.com/UKPLab/CARE/blob/main/backend/webserver/Socket.js#L86 and add a specific variables for the error code. It should be backward compatible. One possible solution would be to create an Error from the Error class and set the error code. If the error code is set, we send it back to the frontend, otherwise we use the previous solultion (in that way we don't need to adapt to much from the existing code). Here is a potential solution that could work: https://stackoverflow.com/a/69166148

let filePath;
if (document.type === this.models['document'].docTypes.DOC_TYPE_HTML ||
document.type === this.models['document'].docTypes.DOC_TYPE_MODAL) {
filePath = `${UPLOAD_PATH}/${document.hash}.delta`;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is not always a delta file for HTML or MODAL documents and also no need, as every edit is still saved in the database. It is enough to only consider the PDF case.

/**
* Parse "ERROR_CODE|message" format from server error
*/
parseErrorMessage(raw) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if it is a good idea to parse error codes like this, I can also find code in different components that is used the same time. Maybe we should integrate error codes properly.

@ututono ututono requested a review from dennis-zyska February 18, 2026 16:56
@ututono
Copy link
Collaborator Author

ututono commented Feb 18, 2026

@dennis-zyska I’ve addressed your requested changes and pushed an updated commit. And also merged the latest dev into this bug fix branch. Could you please take another look?

@NilsDy FYI

@ututono ututono changed the title Fix 10 bug fixes Bug fixes issue #10 Feb 19, 2026

if (!record) {
// Record doesn't exist or was deleted
errorCode = "NOT_FOUND";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can create a new helper function in the utils/generic.js, such that we don't need 5 lines, to be able to reduce it, something like, as an example `throw new GenerateError("NOT_FOUND", "The request ..")

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I introduced a reusable generateError(code, message) helper in utils/generic.js and refactored this branch to use throw generateError(...) here (and in similar socket paths)

this.close();
},

getErrorMessage(response) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We define here the message and codes again, does this make sense? If we send all the data already from the backend to the frontend?

Copy link
Collaborator Author

@ututono ututono Mar 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed the duplicated local error-message map in LoadingModal and same function in other place such as Document.vue and now use backend-provided response.message directly, but I introduced a map titleMap between error code and title of the loading modal to provide more readable information in frontend.

@ututono
Copy link
Collaborator Author

ututono commented Mar 9, 2026

@dennis-zyska I’ve addressed your requested changes and pushed an updated commit. And also merged the latest dev into this bug fix branch. Could you please take another look?

@NilsDy FYI

Also this PR could be reviewed within my team first, I'd assign it to one of team members for first review

@ututono ututono requested a review from dennis-zyska March 9, 2026 19:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Error when document is not loaded

2 participants