Fix queryType parsing to handle string values
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -128,13 +128,15 @@ func ReadQuery(query backend.DataQuery) (QueryModel, error) {
|
|||||||
return model, backend.DownstreamError(fmt.Errorf("could not read query JSON: %w", err))
|
return model, backend.DownstreamError(fmt.Errorf("could not read query JSON: %w", err))
|
||||||
}
|
}
|
||||||
|
|
||||||
queryType, err := queryJSON.Get("queryType").Int64()
|
// Try reading queryType as string first, then as int64
|
||||||
if err != nil {
|
if queryTypeStr, err := queryJSON.Get("queryType").String(); err == nil && queryTypeStr != "" {
|
||||||
|
model.QueryType = queryTypeStr
|
||||||
|
} else if queryType, err := queryJSON.Get("queryType").Int64(); err == nil {
|
||||||
|
model.QueryType = strconv.FormatInt(queryType, 10)
|
||||||
|
} else {
|
||||||
log.DefaultLogger.Warn("could not read query type", "error", err)
|
log.DefaultLogger.Warn("could not read query type", "error", err)
|
||||||
log.DefaultLogger.Debug("setting query type to default value")
|
log.DefaultLogger.Debug("setting query type to default value")
|
||||||
model.QueryType = "0"
|
model.QueryType = "0"
|
||||||
} else {
|
|
||||||
model.QueryType = strconv.FormatInt(queryType, 10)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user