fix(looker): validate explore_references shape instead of panicking#3531
Merged
drstrangelooker merged 1 commit intoJun 26, 2026
Merged
Conversation
The looker-conversational-analytics tool read explore_references with
chained, unchecked type assertions:
LookmlModel: er.(map[string]any)["model"].(string),
Explore: er.(map[string]any)["explore"].(string),
explore_references is declared as an array of free-form maps
(NewMapParameter with an empty value type), so the entries the model
supplies are never schema-validated. A reference that is not an object,
omits "model"/"explore", or carries a non-string value, panics the tool
on the type assertion rather than returning a usable error. Models drop
or mistype those fields often enough that this is reachable in normal
operation.
Move the parsing into a small helper that checks each element and field
and returns a clear agent error, matching the validation already done in
datalineagesearchlineage. Add unit tests covering the valid, empty, and
malformed cases.
Signed-off-by: Yufeng He <40085740+he-yufeng@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces a new helper function parseExploreReferences to safely parse the explore_references parameter in the Looker Conversational Analytics tool. This replaces direct type assertions with proper type checking and validation to prevent potential panics from unexpected shapes. Additionally, a comprehensive suite of unit tests has been added in lookerconversationalanalytics_internal_test.go to cover valid inputs, nil inputs, and various error scenarios. There are no review comments, and I have no feedback to provide.
Contributor
|
/gcbrun |
drstrangelooker
approved these changes
Jun 26, 2026
Contributor
|
/gcbrun |
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.
What
looker-conversational-analyticsparses theexplore_referencestool parameter with chained, unchecked type assertions:explore_referencesis declared as an array of free-form maps (NewMapParameterwith an empty value type), so the entries a model supplies are never schema-validated. Each of these shapes panics the tool instead of returning an error the model can act on:modelorexplorekeymodel/explorevalueModels drop or mistype those fields often enough that this is reachable in normal use, and panicking inside
Invokeis a poor failure mode for a hallucinated argument.Fix
Move the parsing into a small
parseExploreReferenceshelper that validates each element and field and returns a clearutil.NewAgentError, mirroring the validation already done indatalineagesearchlineage. Behaviour for valid input is unchanged.Tests
Added
TestParseExploreReferencescovering valid references, nil/empty input, and the five malformed shapes above. With the helper removed the package no longer builds (the test references it), and with the fixgo test ./internal/tools/looker/lookerconversationalanalytics/passes.go build ./...,go vet, andgofmtare clean.