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

[Bug]: Red overlay on return from validation errors #3767

Closed
kleintom opened this issue Jan 10, 2024 · 6 comments
Closed

[Bug]: Red overlay on return from validation errors #3767

kleintom opened this issue Jan 10, 2024 · 6 comments
Labels
bug An existing function is broken.

Comments

@kleintom
Copy link
Contributor

Steps to reproduce the bug

I've seen varying results over the time I've been playing around with this, so since I'm new I'll just add initial setup steps here, in case I'm overlooking something:
* Update to latest development 2262c10c2c30c70a9552d5c829d6a63c7bcb9639 (this includes the zeitwerk merge).
* I'm using the docker setup, so run `docker-compose build` since there are updated dependancies and then of course `docker-compose up`. I'll put the rest below where it's easier to read.

Screenshot

image

Expected behavior

No response

Additional Screenshots

No response

Environment

Development (docker)

Sandbox Used

No response

Version

2262c10

Browser Used

firefox and chrome

@kleintom kleintom added the bug An existing function is broken. label Jan 10, 2024
@kleintom
Copy link
Contributor Author

As I said, I've gotten varying results from steps similar to the following, but right now steps to reproduce are:
3. Go to the 'Edit loans' task and create a new loan by filling in the minimal Lender Address and Date Return Expected (don't use Gift instead, there's a bug related to that, which is why I was working here).
4. Once the loan is created, clear the Date Return Expected field and click Update Loan.

Actual results: A red overlay screen saying 'Uncaught runtime errors' - see the screenshot. Underneath the overlay you do get the expected temporary 'date_return_expected: or gift status is required' validation error at the bottom of the screen.
In the developer tools the network tab shows a 422 returning the validation error, and the console shows the 422 XHR return as well as an 'Uncaught (in promise)' error.

Expected results: No red overlay and no 'Uncaught (in promise)' errors.

@kleintom
Copy link
Contributor Author

If I add a catch block after the then at

Loan.update(loan.id, { loan: payload, extend: ['roles'] }).then(() => {
TW.workbench.alert.create('Loan was successfully updated.', 'notice')
})
then the red overlays go away (but you still get the 422s, which I think is expected). I assume that's catching the source of the 'Uncaught (in promise)' error, which I assume is what was leading to the red overlay screen.

@kleintom
Copy link
Contributor Author

(I'll say something about what I was seeing earlier; it's just been confusing to me - it's different behavior than what I describe above - but maybe someone more knowledgeable will be able to make sense of it, or if the STR above don't work maybe these will. I was setting out to update one of the validation functions for the Loan model here:

def gift_or_date_expected_required
errors.add(:date_return_expected, ' or gift status is required') if is_gift.nil? && date_return_expected.nil?
end
With unaltered code I wasn't getting any red overlay screens, even when I produced validation fails as in the STR above. But as soon as I changed that validation function at all, I would get a red overlay. I wanted to change is_gift.nil? to is_gift.blank? but that change was producing red overlays where the original code was not. Any other change I made to the validation function, even just removing the if all together, would produce a red overlay, and then when I changed the source back to the original the red overlay would go away. Maybe I was just missing something though!)

@kleintom
Copy link
Contributor Author

You can also get a red overlay screen and 'Uncaught (in promise)' from a validation error by going to the New Namespace task and clicking Create without filling anything in.
On sandbox today, both the New Namespace and the Edit Loan STR show a 422 in the Network tab and an 'Uncaught (in promise)' in the Console (more confusion for me!).

@jlpereira
Copy link
Member

@kleintom both overlay messages should be fixed now. Also now you should see a more informative message about the error and not "[Object object]"

Reopen if you still getting the same error

jlpereira added a commit that referenced this issue Jan 10, 2024
@kleintom
Copy link
Contributor Author

Thanks @jlpereira!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An existing function is broken.
Projects
None yet
Development

No branches or pull requests

2 participants