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 to give back error when path not found #194

Merged
merged 2 commits into from
Feb 2, 2021
Merged

Fix to give back error when path not found #194

merged 2 commits into from
Feb 2, 2021

Conversation

nakabonne
Copy link
Contributor

@nakabonne nakabonne commented Feb 2, 2021

Fixes #193

This is happening because Path.Read() assumes it's going to have a non-nil Node if no error returned. But it could give back a nil Node even if no error was given.

I little poked around the codebase and most of the callers of Path.FilterFile() assume the same does.

It would be great if you could give me any feedback.

pipecd-bot pushed a commit to pipe-cd/pipecd that referenced this pull request Feb 2, 2021
**What this PR does / why we need it**:
Currently it panics if you give non-existence yaml-path to Event watcher. This is happing due to go-yaml's issue. So I sent a PR to fix them: goccy/go-yaml#194

Until merging it, I just settled on parsing an AST node ourselves as a workaround.


**Which issue(s) this PR fixes**:

Fixes #1470

**Does this PR introduce a user-facing change?**:
<!--
If no, just write "NONE" in the release-note block below.
-->
```release-note
NONE
```

This PR was merged by Kapetanios.
@goccy
Copy link
Owner

goccy commented Feb 2, 2021

Thank you for the great PR ( and Issue ) !
As you've fixed, it seems good to return an error if the path isn't found.

Only one point, the error list is written here, can you add an error like ErrNotFoundNode and return it ?
You can also add information by wrapping and returning it like
errors.Wrapf(ErrNotFoundNode, "failed to find path %s", p.node()).

@nakabonne
Copy link
Contributor Author

Thank you for the quick response. Okay, let me do so.

@codecov-io
Copy link

Codecov Report

Merging #194 (e838d7c) into master (f6ab5cc) will not change coverage.
The diff coverage is 0.00%.

@@           Coverage Diff           @@
##           master     #194   +/-   ##
=======================================
  Coverage   76.20%   76.20%           
=======================================
  Files          11       11           
  Lines        2937     2937           
=======================================
  Hits         2238     2238           
  Misses        468      468           
  Partials      231      231           

@nakabonne
Copy link
Contributor Author

@goccy I addressed it. PTAL 😄

@goccy
Copy link
Owner

goccy commented Feb 2, 2021

Thank you for the contribution ! I will merge it !

@goccy goccy merged commit d984d1d into goccy:master Feb 2, 2021
@nakabonne nakabonne deleted the fix-path-not-found branch February 2, 2021 05:37
pipecd-bot pushed a commit to pipe-cd/pipecd that referenced this pull request Feb 2, 2021
**What this PR does / why we need it**:
Since goccy/go-yaml#194 has been merged and released, we can close #1531.

Besides, goccy/go-yaml#196 is soon-to-be-released, hence we can also close #1530.

**Which issue(s) this PR fixes**:

**Does this PR introduce a user-facing change?**:
<!--
If no, just write "NONE" in the release-note block below.
-->
```release-note
NONE
```

This PR was merged by Kapetanios.
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.

Panic when reading from non-existent path
3 participants