Skip to content

feat(search): add support for saved search terms in grammar#2418

Open
jcscottiii wants to merge 1 commit intomainfrom
feat/saved-search-grammar
Open

feat(search): add support for saved search terms in grammar#2418
jcscottiii wants to merge 1 commit intomainfrom
feat/saved-search-grammar

Conversation

@jcscottiii
Copy link
Copy Markdown
Collaborator

@jcscottiii jcscottiii commented Apr 13, 2026

feat(search): add saved: and hotlist: terms to search grammar

This PR updates the search grammar to support saved: and hotlist: search terms. It implements the necessary parser visitor methods and adds unit tests to verify parsing.

These terms are intended to be expanded upstream (e.g., in the backend before SQL generation), so they are currently added as no-ops in the filter builder with documentation noting they are handled upstream.

Additionally, this PR updates the search grammar skill documentation to include guidelines on error handling and query validation, emphasizing that semantic errors should return 400 Bad Request instead of 500.

Changes:

  • antlr/FeatureSearch.g4: Added saved and hotlist terms to the grammar.
  • lib/gcpspanner/searchtypes/: Updated visitor and constants for new terms.
  • lib/gcpspanner/feature_search_query.go: Added stub handling for new terms, noting they are handled upstream.
  • lib/gcpspanner/searchtypes/features_search_parse_test.go: Added unit tests for the new terms.
  • .agent/skills/webstatus-search-grammar/SKILL.md: Added error handling guidelines and a note about the ANTLR generation environment.

Updates the ANTLR grammar to support 'saved' terms (e.g., saved:ID) in feature searches. Includes the necessary visitor implementations and tests to parse and handle these new terms. Also updates the search grammar skill documentation to reflect these changes.
@jcscottiii jcscottiii force-pushed the feat/saved-search-grammar branch 2 times, most recently from f3801cf to e4b8703 Compare April 15, 2026 18:44
@jcscottiii jcscottiii requested review from jrobbins and neilv-g April 15, 2026 19:39
if err == nil {
t.Fatal("expected error for unexpanded saved search, got nil")
}
expectedErr := "unexpected unexpanded search identifier: saved"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The smallest of nits and honestly more of a comment/discussion point for future CLs rather than this one.

We use fmt.Errorf already in a ton of places in the codebase, but it would probably be good if over time we moved toward defined error types to avoid string matching on error messages in UTs. I'll try to be aware of this going forward myself, but I thought I would mention it as well.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. The rest of the errors in this file use the errors.Is method to check. This one definitely should not be doing something brittle like that. Will update!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants