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 the context_lines option not skipping reading the source code if its value is set to null #1003

Merged
merged 4 commits into from
May 5, 2020
Merged

Fix the context_lines option not skipping reading the source code if its value is set to null #1003

merged 4 commits into from
May 5, 2020

Conversation

ste93cry
Copy link
Collaborator

@ste93cry ste93cry commented Apr 26, 2020

Q A
Branch? 2.3
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
License MIT

I noticed that setting the context_lines option to 0 null does not prevent the source code from being read and attached to each frame of a stacktrace, but the documentation says it should work this way. In addition to this, the validation was missing leading to bad things when such option was set to a value lower than zero, so I took the time to fix this too.

Copy link
Collaborator

@Jean85 Jean85 left a comment

Choose a reason for hiding this comment

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

Looking at the docs, this seems the wrong behavior: https://docs.sentry.io/platforms/php/#context_lines

If null is set as the value, no source code lines will be added to each stack trace frame. By default this option is set to 3.

I tend to agree with this, because it allows to have just the user to have only the offending rule; so, null is "Do not upload my source code" where instead 0 is "upload only the offending line, no context lines".

@ste93cry
Copy link
Collaborator Author

so, null is "Do not upload my source code" where instead 0 is "upload only the offending line, no context lines".

While you are right that the documentation says a different thing, and from what I see the Go SDK follows the same reasoning, I don't think that it really makes sense that setting the option to 0 still sends the offending line. As there is there is no distinction for the user between pre/post context lines and the context line itself, as a user I would not expect that 0 means 1 and null means 0, wouldn't you?

@Jean85
Copy link
Collaborator

Jean85 commented Apr 28, 2020

It seems we're not agreeing on the meaning of "context". Context is the surrounding of the subject, so in this case the lines above and below the one in the stacktrace. That's why I consider that the correct approach.

@HazAT can you weight in here? Is this interpretation the right and meant one?

@ste93cry
Copy link
Collaborator Author

Context is the surrounding of the subject, so in this case the lines above and below the one in the stacktrace.

After reading the linked article I now think that you are proven right, but to be on the safe side let's wait anyway for a final word by @HazAT

@HazAT
Copy link
Member

HazAT commented Apr 28, 2020

So the context_lines are really focused around the pre_context and post_context. So setting this to 0 on makes pre_context & post_context empty.
null should not even send the offending line.

@ste93cry ste93cry requested a review from Jean85 April 28, 2020 16:38
@ste93cry ste93cry changed the title Fix the context_lines option not skipping reading the source code if its value is set to 0 Fix the context_lines option not skipping reading the source code if its value is set to null Apr 29, 2020
Copy link
Collaborator

@stayallive stayallive left a comment

Choose a reason for hiding this comment

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

Good change/fix 👍

@ste93cry ste93cry merged commit 97bbca2 into getsentry:master May 5, 2020
@ste93cry ste93cry deleted the fix/context-lines-option-cannot-be-disabled branch May 5, 2020 13:57
ste93cry added a commit that referenced this pull request May 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants