Fix: Handle count 1 with removeBorderValues returning empty results#438
Draft
Fix: Handle count 1 with removeBorderValues returning empty results#438
Conversation
Author
|
@GermanBluefox 👋 This repository doesn't have Copilot instructions. With Copilot instructions, I can understand the repository better, work faster and produce higher quality PRs. I can generate a .github/copilot-instructions.md file for you automatically. Click here to open a pre-filled issue and assign it to me. I'll write the instructions, and then tag you for review. |
Co-authored-by: GermanBluefox <4582016+GermanBluefox@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Using count 1 with removeBorderValues can return empty query even if we have datapoints in time range (assumption)
Fix: Handle count 1 with removeBorderValues returning empty results
Sep 13, 2025
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.
This PR fixes an issue where using
getHistorywithremoveBorderValues: trueandcount: 1would return empty results even when datapoints existed in the database.Problem
When users specified these parameters together:
They would sometimes get empty results (
[]) even though:count: 1, the same query would return multiple resultsRoot Cause
The issue occurred in the
beautifyfunction inlib/aggregate.js. When InfluxDB returned data points that were slightly outside the exact time range (which can happen due to timing precision or grouping behavior), the beautify function would filter out all data points based on strict timestamp boundaries. Withcount: 1, if the only available data point was outside the precise time boundaries, it would be completely filtered out, resulting in empty results.Solution
Added intelligent edge case handling in the beautify function that:
Detects the problematic scenario: When
removeBorderValues: trueandcountare specified together, and all data was filtered out due to time range restrictions but original data existed before filteringRestores closest data points: Instead of returning empty results, the fix identifies and restores the closest data point(s) to satisfy the count requirement
Preserves existing behavior: The fix only activates in the specific edge case and doesn't affect any other functionality
Testing
The fix has been thoroughly tested with multiple scenarios:
removeBorderValues: falsebehaviorExample of the fix in action:
Fixes #261.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.