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

Json parse failure handling #156

Merged
merged 1 commit into from
Feb 19, 2019
Merged

Json parse failure handling #156

merged 1 commit into from
Feb 19, 2019

Conversation

bhornseth
Copy link
Member

Trying to wrap up the few outstanding v2 changes and I need some design input on this one

I can't remember if we have an internal ticket tracking this and didn't find one when I looked briefly.

questions:

  • is it worth having a SparkApi (gem) exception specifically for this, or should we close Improve handling of non-JSON responses #139 as Won't Fix and keep the behavior how it's always been? The main benefit I see in adding a custom exception is we can have more actionable error messages in the logs, even if we don't catch the exceptions.
  • if we do move forward with this, should the error instance include the request metadata? I could see it being nice to have this error outside the SparkApi::ClientError hierarchy so handlers that catch that generic exception continue to behave the same and don't start picking up this new exception as well, but I'm curious to hear other thoughts on that.

Catch MultiJson::ParseError exceptions and return a
SparkApi::InvalidJSON exception instead
@@ -1,3 +1,9 @@
v2.0.0
- Drop support for ruby 1.9.3, require a minimum of ruby 2.2
Copy link
Contributor

Choose a reason for hiding this comment

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

👋

s.add_development_dependency 'rb-readline'
s.add_development_dependency 'rb-fsevent'
s.add_development_dependency 'simplecov'
s.add_development_dependency 'rake'
Copy link
Contributor

Choose a reason for hiding this comment

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

I think I'm OK with keeping the dependencies pretty wide open, but you may want to be tighter on dev dependencies. This is of course assuming we don't checking a lock file.

I don't have a clear solution here, but there is a definite problem with working on a gem because one's local versions are vastly different from the main author.

Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps a guideline here is to limit to >= an exact version that is known to work.

Copy link
Member Author

Choose a reason for hiding this comment

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

If I understand you correctly, you're talking about the problem that happens when your local copy has preinstalled gems, and the tests all pass, but the from-scratch job on Travis or our build server fails, either when installing deps or because a changed dependency caused a test to fail?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yup, exactly. Everything works fine up until a new version of the dependency is released, and trashes your next build. It's a nuisance, and can be downright maddening to figure out the last good list of deps.

@bhornseth bhornseth changed the base branch from master to v2 February 18, 2019 21:44
@wlmcewen
Copy link
Contributor

As to your questions, I very much think it's worthwhile handling these errors in the gem, and present a more appropriate message. The multijson response is rather terrible.

Including the request and response information as a part of the error is something I've wanted to do for a long time, hell, even providing a clean manner to log this information for successful requests wouldn't be bad, so long as overhead was manageable, or at least the feature was configurable.

@bhornseth
Copy link
Member Author

Apologies: I unintentionally made this PR against master, not the v2 base that was intended. I've updated it and it's a much smaller review now 🤣

@wlmcewen
Copy link
Contributor

MUCH SMALLER

@bhornseth
Copy link
Member Author

if you want to review the v2 changes, those are over here 👉 #153 😄

@bhornseth bhornseth merged commit c284254 into v2 Feb 19, 2019
@bhornseth bhornseth deleted the json-parse-failure-handling branch February 19, 2019 14:55
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.

3 participants