Repository navigation
Kostal Piko: cache http readings - #36659
Merged
Merged
Conversation
This reverts commit 8c7aeef.
Contributor
Linked issuesChecked at commit 822c018 #36658 uncached request repeated within 1s warnings with Kostal Piko BA (multiple meters on same dxs.json endpoint) · 1 of 1 met
|
Contributor
There was a problem hiding this comment.
Hey - I've found 3 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="plugin/http.go" line_range="271" />
<code_context>
// the response should be cached. It fires once per url to avoid log spam.
func repeatedGet(url string, now time.Time) bool {
+ // a query selects the values to read, such requests are not expected to be cached
+ if strings.Contains(url, "?") {
+ return false
+ }
</code_context>
<issue_to_address>
**Uncached query polling goes unnoticed**
When a repeated uncached GET uses query parameters for metadata or another purpose rather than selecting values to read, `repeatedGet` returns false for every URL containing `?`, so the request path never logs its uncached-repeat warning and operators miss polling that may need caching.
Limit the exemption to query forms known to select values, or preserve repeat warnings for other query URLs.
</issue_to_address>
### Comment 2
<location path="plugin/http.go" line_range="271" />
<code_context>
// the response should be cached. It fires once per url to avoid log spam.
func repeatedGet(url string, now time.Time) bool {
+ // a query selects the values to read, such requests are not expected to be cached
+ if strings.Contains(url, "?") {
+ return false
+ }
</code_context>
<issue_to_address>
**Fragment question marks suppress warnings**
When a configured URI has no query but its fragment contains `?`, `repeatedGet` mistakes the fragment’s `?` for a query and skips tracking the URL, even though HTTP omits fragments from requests; repeated uncached GETs therefore produce no warning.
Parse the URL and check its query component instead of searching the raw URL for `?`.
</issue_to_address>
### Comment 3
<location path="plugin/http_test.go" line_range="232-234" />
<code_context>
- require.False(t, repeatedGet("http://q.test/path?ts=1", t0))
- require.False(t, repeatedGet("http://q.test/path?ts=2", t0.Add(300*time.Millisecond)))
+ // urls with query params are exempt, even when repeated
+ query := "http://q.test/api/dxs.json?dxsEntries=33556229"
+ require.False(t, repeatedGet(query, t0))
+ require.False(t, repeatedGet(query, t0.Add(300*time.Millisecond)))
}
</code_context>
<issue_to_address>
**New test case stays positional**
When a new request scenario is added to this multi-case test, the added query-URL scenario uses positional assertions in `TestRepeatedGet` instead of a struct-driven table, so the expanded multi-case test does not follow the repository's required test pattern.
Represent the scenarios as cases in a struct-driven table and run them as table subtests.
</issue_to_address>
andig
enabled auto-merge (squash)
November 27, 2026 16:58
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.
fixes #36658
The Kostal Piko templates read each value from its own
dxs.json?dxsEntries=...URL, and no URL is used twice in a template. The warning fires because the same full URL is fetched twice within a second, and the inverter sends no cache headers. Every http source inkostal-piko-pv(Piko, Piko BA) andkostal-piko-hybridnow caches its reading, configurable through a newcacheparam with default 1s. Query parameters stay part of the cache key, so different readings never share a cached response.🤖 Generated with Claude Code