Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Full-Stack Signals] Operation validation error message is not propagated to the client #2916

Open
taefi opened this issue Nov 20, 2024 · 1 comment · May be fixed by #2939
Open

[Full-Stack Signals] Operation validation error message is not propagated to the client #2916

taefi opened this issue Nov 20, 2024 · 1 comment · May be fixed by #2939
Assignees
Labels
bug Something isn't working hilla Issues related to Hilla

Comments

@taefi
Copy link
Contributor

taefi commented Nov 20, 2024

Describe the bug

When an operation validator is defined for a full-stack signal, no matter what the rejection error is, on the client side, the reason is: "server rejected the operation".

Expected-behavior

To be able to show a the validation error message that is defined for the server-side Signal instance's validator.

Reproduction

Define an operation validator for signal instance that is returned to the client:

private final ListSignal<Message> chatSignal = new ListSignal<>(Message.class).withOperationValidator(
            operation -> {
                if (operation instanceof ValueOperation<Message> valueOp) {
                    if (valueOp.value().text().toLowerCase().contains("bad")) {
                        return ValidationResult.reject("Bad words are not allowed");
                    }
                }
                return ValidationResult.allow();
            });

or even with a readonly signal:

private final ListSignal<Message> guestSignal = chatSignal.asReadonly();

When user tries to insert a message to any of the above signals instances, and the operation validation gets rejected, the only available reason for in the onrejected callback is always: "server rejected the operation":

chatSignal.insertLast({text: 'Hi', author:'John'})
               .result.then(() => {}, (reason) => Notification.show(reason));

System Info

Vaadin: 24.6.0.alpha4
Hilla: 24.6.0.alpha5

@taefi taefi added bug Something isn't working hilla Issues related to Hilla labels Nov 20, 2024
@platosha
Copy link
Contributor

Let's log the rejection message on the server. Most of the time we don't need to disclose the message to the client.

The client-side error message could say: “See the server log for more details.”

@taefi taefi self-assigned this Nov 29, 2024
taefi added a commit that referenced this issue Nov 29, 2024
@taefi taefi linked a pull request Nov 29, 2024 that will close this issue
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working hilla Issues related to Hilla
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants