Allow queries without authentication if no API key is provided - #70
Merged
Merged
Conversation
Add tests for Sql method with and without authentication These tests verify that queries work both with and without API key against local and cloud Spice runtimes.
sgrebnov
approved these changes
Jan 6, 2026
There was a problem hiding this comment.
Pull request overview
This pull request enhances authentication handling in the query logic to support optional authentication and adds comprehensive test coverage for both authenticated and unauthenticated query scenarios. The changes enable SQL queries to execute without authentication when no API credentials are provided, which is essential for local runtime environments.
Key Changes:
- Modified
queryInternalfunction to conditionally authenticate only when bothappIdandapiKeyare provided - Added
TestSqlWithoutAuthto verify SQL query execution against local Spice runtime without authentication - Added
TestSqlWithAuthto verify SQL query execution against Spice Cloud with authentication
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| query.go | Updated authentication logic to only authenticate when credentials are provided, using the original context when credentials are absent |
| query_test.go | Added comprehensive test coverage for authenticated and unauthenticated SQL queries with health checks, readiness validation, and dataset queries |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
🗣 Description
This pull request improves authentication handling for both cloud and local Spice runtimes, refactors tests and benchmarks to skip cloud tests if the API key is not set, and introduces more robust test coverage for authenticated and unauthenticated queries. The changes also update parameterized query tests to use the
taxi_tripsdataset instead of the previous TPC-H dataset, making the tests more relevant to current data sources.Tests updated to use https://spice.ai/spiceai/quickstart Spice Cloud app
Authentication Handling Improvements
Updated all tests and benchmarks to skip cloud authentication tests if
SPICE_API_KEYis not set or empty, instead of using a hardcoded test API key. This ensures sensitive credentials are handled securely and prevents accidental test execution against the cloud without proper authentication. [1] [2] [3] [4] [5] [6] [7]Modified the internal query logic in
query.goto only perform authentication if bothappIdandapiKeyare provided, allowing unauthenticated queries against local runtimes.Test Coverage Enhancements
query_test.goto explicitly verify that SQL queries work both with and without authentication, including readiness and health checks for local and cloud Spice runtimes.Parameterized Query Test Updates
adbc_test.goto use thetaxi_tripsdataset instead of TPC-H, updating field names, query parameters, and validation logic to match the new schema. This makes the tests more relevant and easier to maintain. [1] [2] [3]Code Clean-up
TEST_API_KEYconstant fromquery_test.goand replaced all usages with environment variable checks.These changes collectively improve security, reliability, and maintainability of tests and benchmarks for both local and cloud environments.