-
Notifications
You must be signed in to change notification settings - Fork 310
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
invoice.save returns false but invoice.errors is empty #538
Comments
Update: found the specific error by adding a logger and seeing the actual HTTP response. The |
I have the same problem. Upgrading to 3.00 has broken validation errors on all models. |
It seems in version 2.18 the save! (bang) method was introduced. Previously validation errors would throw an exception. There is no code, that I could find, that will populate the errors from the validation errors in the XML response. If you use the bang method (save!) then you can catch the original validation exception and handle this yourself. |
I'm not seeing this behaviour.
Did someone fix it? Feel free to re-open if this issue persists, but I'm unable to reproduce based on the above details provided. |
Those are all local validation errors. From memory, this was about errors returned from the API not been populated anywhere. So if the contact already exists for example, the response is just captured and disregarded. |
Right, thanks for details. Yes, I've also noticed that OAuth related errors such as token invalid / expired, return false, but it's unclear unless you're catching those errors from save! |
Yes, our original logic utilised the nature of save throwing errors so it was simple for us to switch to the bang method (after the 2.18 change) to get back to where we were. Ideally though the save method would do as OP expected. |
Ok, seems like a relatively easy fix. None of the error classes were included in the OAuth2 class. I'll get a PR up shortly, @toxaq I'll ping you to review, be good to have some eyes on it as I'm a bit dubious on the test coverage. edit: That's not it. Investigating further |
I would probably start around here: xeroizer/lib/xeroizer/record/base.rb Line 110 in b78a9a0
The exceptions are still being raised, as per the pre-2.18 functionality, they're just captured and dumped. |
Could be as simple as
There's nothing else available error wise. This is where they are extracted from the response xeroizer/lib/xeroizer/exceptions.rb Line 37 in cce6733
|
Having the same issue here, any updates? |
@rjaus I'm trying to work on a PR for this, but struggling to run individual tests. I'll make a separate issue for this (I don't normally use minitest, so could be a dumb error). |
This does a very basic fix to waynerobinson#538 by parsing the thrown ApiException. This won't help if an ApiException isn't thrown (unexpected error). It also feels rather ugly having to catch and re-raise, but any other change would be a very significant refactor.
I've made a pretty crappy little PR for this - it does tick the basic box of providing an errors object, but it's not super nice. I feel like the errors object (it's an array of arrays) could be abstracted and encapsulated (this is a pre-existing issue) so you don't have to know its structure to add an error and extract the messages. Could even go as far as adapting an ActiveModel::Errors approach. I'm not too happy with using the Exceptions as the mechanism for communicating the validation errors between the http layer and the record layer. However I don't have a clear vision how to change this. |
I think that these two errors should never be caught by
(see #551 (comment)) |
invoice
object is built with some paramsHow do I know what caused
invoice.save
to return false?The text was updated successfully, but these errors were encountered: