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

fix: stringify js options when serialized for the payload #1089

Merged
merged 1 commit into from
Apr 4, 2022

Conversation

waltjones
Copy link
Contributor

Description of the change

Background
Rollbar-gem includes middleware that configures Rollbar.js for the javascript client. The Rollbar.js options are passed as part of the Rollbar-gem config. Some valid js options are javascript functions that by default, the Ruby JSON serializer will convert to strings, however the js config needs these as functions not strings.

In #821 a custom type was added that allows these to be passed to the js config correctly as functions. When serializing the same options to the payload (for the diagnostic configured_options key) these were passed as strings.

In #890 the payload serialization was refactored, and the js functions were no longer stringified correctly in the payload. The test automation didn't cover this case and it went unnoticed.

The fix
This PR signals to the custom data type whether it should stringify the js functions by optionally sending a subclassed state object when calling JSON.generate. The subclass is necessary because the state class doesn't allow custom attributes to be added.

This PR also adds a test to confirm the payload serialization.

Type of change

  • Bug fix (non-breaking change that fixes an issue)

Related issues

Fixes #1086

Development

  • Lint rules pass locally
  • The code changed/added as part of this pull request has been covered with tests
  • All tests related to the changed code pass in development

Code review

  • This pull request has a descriptive title and information useful to a reviewer. There may be a screenshot or screencast attached
  • "Ready for review" label attached to the PR and reviewers assigned
  • Issue from task tracker has a link to this pull request
  • Changes have been reviewed by at least one other engineer

@waltjones waltjones requested review from cyrusradfar and ijsnow March 30, 2022 22:11
@matux
Copy link

matux commented Apr 1, 2022

Looks good. Just two minor non-blocking comments.

@waltjones waltjones merged commit ef5cb57 into master Apr 4, 2022
@waltjones waltjones deleted the waltjones/1086/stringify-js-options branch June 27, 2023 18:14
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.

Posting items fails serverside with "err: 1: invalid or missing instance"" when using checkignore
3 participants