fix: return None instead of empty string for unset string fields#236
Open
nedeadinside wants to merge 1 commit into
Open
fix: return None instead of empty string for unset string fields#236nedeadinside wants to merge 1 commit into
nedeadinside wants to merge 1 commit into
Conversation
String fields decoded from C via ffi.string().decode() returned "" when the underlying C char array was empty (e.g. application_name when protocol is not detected). This was inconsistent with non-sync mode where the same fields are explicitly set to None, and caused a subtle pandas bug: DataFrame built from NFlow had no nulls, but after to_csv()/read_csv() round-trip NaN values appeared.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
String fields decoded from C structures via
ffi.string().decode()returned""when the underlying C char array was empty (e.g.client_fingerprint,requested_server_name. etc.).This was inconsistent with non-sync mode, where the exact same fields are explicitly set to
None:The inconsistency caused a subtle data quality issue with pandas: a
DataFramebuilt directly fromNFlowobjects showed no null values, but after ato_csv()/read_csv()round-tripNaNvalues appeared in the affected columns because pandasread_csv()interprets empty CSV cells asNaNwhile an empty Python string""is not null.Fix: added
or Noneafter every.decode()call for optional string fields, so that an empty decoded string is normalised toNone. Applied consistently in__init__(sync branch),sync()method, andsystem_visibility_modeinitialisation block.Fixes # (no existing issue)
Type of change
How Has This Been Tested?
Reproduced manually with script like that:
Checklist