fix: map __ts_timeline_id to timeline name in to_pandas - #3895
fix: map __ts_timeline_id to timeline name in to_pandas#3895SkxOverKill wants to merge 2 commits into
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request updates the to_pandas method in the Python API client to map the __ts_timeline_id field to its corresponding timeline name, and adds a unit test to verify this behavior. The review feedback highlights potential issues with timeline lookups, specifically a type mismatch if the timeline ID is a string and the lack of a fallback if the timeline is not found. It suggests casting the ID to an integer and falling back to the original ID if the lookup fails, along with updating the unit test to cover string IDs.
|
Thanks for the review. I pushed b31705b addressing both findings: string-form timeline IDs are normalized for lookup, unknown IDs retain their original value as a fallback, and the regression now covers integer, string, and missing IDs across both affected output columns. I also fixed the Black and PyLint failures. The PR description now documents the behavior and verification results. |
Summary
Fixes timeline-name mapping in
Search.to_pandas()when_sourceor__ts_timeline_idis requested as a return field.Root Cause
The field-mapping block contained two related defects:
__ts_timeline_idbranch assigned its result to_source, so callers received a spurious or overwritten_sourcevalue instead of the requested__ts_timeline_idcolumn.__ts_timeline_idfrom the top level of the OpenSearch hit. The ID is stored within the event's_source, so the lookup returnedNoneinstead of the timeline name.Timeline IDs may also be represented as strings in event data while sketch timeline objects expose integer IDs. Without normalization, valid string IDs silently miss the timeline lookup.
Implementation
_sourceand__ts_timeline_idindependently when requested.Test Coverage
The regression test covers:
_sourceand__ts_timeline_idoutput columns.Verification