-
Notifications
You must be signed in to change notification settings - Fork 78
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: occasional panic when watched YAML files change #1246
Conversation
✅ Deploy Preview for polite-licorice-3db33c canceled.
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1246 +/- ##
==========================================
+ Coverage 73.69% 77.21% +3.51%
==========================================
Files 32 19 -13
Lines 3140 1549 -1591
==========================================
- Hits 2314 1196 -1118
+ Misses 717 272 -445
+ Partials 109 81 -28 ☔ View full report in Codecov by Sentry. |
I bet that this is due to the way files are saved/changed on different systems. I believe when I save a file in vscode on my Linux machine, it results in multiple fs events, some of which have no content. Thanks @dinhlockt02 for your effort. I will give this a review soon. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for identifying the root cause. I think this is a good enough fix for the bug :)
Signed-off-by: Tran Dinh Loc <dinhlockt02@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
@dinhlockt02 Thanks so much for your contribution. The only change I will make is the PR title, so it might be a bit easier to understand in our release notes. |
🤖 I have created a release *beep* *boop* --- <details><summary>flagd: 0.9.1</summary> ## [0.9.1](flagd/v0.9.0...flagd/v0.9.1) (2024-03-15) ### 🐛 Bug Fixes * **deps:** update module google.golang.org/protobuf to v1.33.0 [security] ([#1248](#1248)) ([b2b0fa1](b2b0fa1)) * update protobuff CVE-2024-24786 ([#1249](#1249)) ([fd81c23](fd81c23)) ### ✨ New Features * serve sync.proto on port 8015 ([#1237](#1237)) ([7afdc0c](7afdc0c)) ### 🧹 Chore * move packaging & isolate service implementations ([#1234](#1234)) ([b58fab3](b58fab3)) </details> <details><summary>flagd-proxy: 0.5.1</summary> ## [0.5.1](flagd-proxy/v0.5.0...flagd-proxy/v0.5.1) (2024-03-15) ### 🐛 Bug Fixes * update protobuff CVE-2024-24786 ([#1249](#1249)) ([fd81c23](fd81c23)) ### 🧹 Chore * move packaging & isolate service implementations ([#1234](#1234)) ([b58fab3](b58fab3)) </details> <details><summary>core: 0.8.1</summary> ## [0.8.1](core/v0.8.0...core/v0.8.1) (2024-03-15) ### 🐛 Bug Fixes * occasional panic when watched YAML files change ([#1246](#1246)) ([6249d12](6249d12)) * update protobuff CVE-2024-24786 ([#1249](#1249)) ([fd81c23](fd81c23)) ### 🧹 Chore * move packaging & isolate service implementations ([#1234](#1234)) ([b58fab3](b58fab3)) </details> --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Signed-off-by: OpenFeature Bot <109696520+openfeaturebot@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This PR
At the moment, the yamlToJSON will convert
[]byte("")
to"null"
. While "null" is a normal string, it will bypass all validator and lead to panic.Related Issues
Fixes #1242
Notes
I found that sometime, the os.Readfile will return empty byte and no error, this will cause the yamlToJSON convert the rawData ("") to jsonData ("null").

Moreover, when I check the log, the watcher is reading file content a lot at a times for checking file changes, so it could be the reason why os.Readfile return empty byte?
Follow-up Tasks
I think we have to check the behavior of os.Readfile?
How to test