fix: correct orgId misuse, defer-after-error, and log format in datasource plugin - #33
Open
belowzeroff wants to merge 1 commit into
Open
Conversation
…ource plugin - Remove orgId: this.id from metricFindQuery (datasource ID != org ID; Grafana backend derives org from session context) - Move defer f.Close() after error check in getConfig to avoid panic on nil *os.File when testConfig.csv is missing - Fix log.DefaultLogger.Error call: Grafana SDK uses structured key-value pairs, not printf-style formatting
belowzeroff
force-pushed
the
fix/logic-bugs-orgid-defer-logformat
branch
from
July 23, 2026 10:54
e2014af to
9e3beb8
Compare
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.
Summary
Three logic bug fixes:
Incorrect
orgIdinmetricFindQuery—orgIdwas set tothis.id(datasource instance ID), which is semantically wrong. Grafana derives the org ID from the session context on the backend side, so this field was both wrong and unnecessary.defer f.Close()before error check — IngetConfig(), ifos.Open("../../test/testConfig.csv")fails,fis nil anddefer f.Close()causes a nil pointer panic. Moved thedeferafter the error check.log.DefaultLogger.Errorused printf-style format — Grafana SDK logger uses structured key-value pairs (key, value), not%sformat strings. Changed"Error decoding query and field -%s", err.Error()to"Error decoding query and field", "error", err.Error().Verification
go build ./...succeedsgo vet ./...shows no new warnings