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

Handle JSON parse errors in watch implementation #250

Merged
merged 1 commit into from
May 29, 2019
Merged

Handle JSON parse errors in watch implementation #250

merged 1 commit into from
May 29, 2019

Conversation

silasbw
Copy link
Contributor

@silasbw silasbw commented May 26, 2019

This change "handles" JSON parse errors in the watch implementation by
ignoring them: the JSONStream implementation ignores parsing errors.

The request might result in invalid JSON if, for example, the HTTP connection
is abruptly terminated (and a partial line is piped to the transform stream).

The code this commit replaces would raise an uncaught exception exception on
parse errors. An alternative approach to this commit would invoke the done
callback with parse errors, but that could result in multiple invocations of
the done callback.

@k8s-ci-robot k8s-ci-robot added do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels May 26, 2019
@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label May 26, 2019
src/watch.ts Outdated
@@ -1,4 +1,5 @@
import { LineStream } from 'byline';
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this still used?

Also not sure the linter didn't pick this up.

package.json Outdated
@@ -56,6 +56,7 @@
"byline": "^5.0.0",
Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn't seem to be needed anymore either?

This change "handles" JSON parse parse errors in the watch implementation by
ignoring them: the JSONStream implementation ignores parsing errors.

The request might result in invalid JSON if, for example, the HTTP connection
is abruptly terminated (and a partial line is piped to the transform stream).

The code this commit replaces would raise an uncaught exception exception on
parse errors. An alternative approach to this commit would invoke the `done`
callback with parse errors, but that could result in multiple invocations of
the `done` callback.
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. label May 28, 2019
@drubin
Copy link
Contributor

drubin commented May 28, 2019

@silasbw Thanks for fixing this and for adding a test

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 28, 2019
@drubin
Copy link
Contributor

drubin commented May 28, 2019

/assign @brendandburns

@brendandburns
Copy link
Contributor

/approve

thanks!

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: brendandburns, silasbw

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 29, 2019
@k8s-ci-robot k8s-ci-robot merged commit f4304dd into kubernetes-client:master May 29, 2019
@silasbw silasbw deleted the parse0 branch May 29, 2019 16:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants