You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
Currently the test coverage of the project is nearly non-existent. We do have and use Vitest as a dependency in the Starbase project already that future tests should also use. The idea is to begin accumulating test coverage throughout the entire project.
Goal is to bring test coverage up to above 75% with meaningful tests.
Describe the solution you'd like
Important: Tests should not just be made for line coverage, they should also include meaningful tests that help reveal when issues arise. For example, if we were to write a test for our LiteREST code to see if making a request fetched data we would pass it potentially:
Plan: Add comprehensive Vitest unit tests in src/allowlist/index.test.ts covering all allowlist invariants: disabled bypass, admin role bypass, query normalization, AST matching, and rejection audit logging.
I found a clean, non-overlapping coverage slice in the plugin utilities that currently lacks unit test coverage:
plugins/cron/utils.ts and plugins/cron/index.ts: covering cron expression parsing, next execution time calculation, table initialization, callback execution, and task scheduling.
plugins/resend/index.ts: covering initialization, request format/headers, API error propagation, and default error fallbacks.
Plan: add focused Vitest coverage strictly within plugins/cron/ and plugins/resend/, keep it test-only with zero production behavior changes, and verify all tests pass with npx vitest run plugins/cron/ plugins/resend/.
🛠️ Production Implementation & Technical Verification
Root Cause Analysis & Architectural Fault Line:
Missing Allowlist Verification (src/allowlist/index.ts): src/allowlist/index.ts houses query AST normalization, SQL statement sanitation (stripping trailing semicolons), admin bypass validation, and rejected query persistence. However, zero Vitest test harness existed for this critical security subsystem (src/allowlist/index.test.ts was completely absent).
LiteREST Edge-Case Gaps (src/literest/index.ts): While src/literest/index.test.ts tested standard queries, it lacked negative edge-case test coverage explicitly specified by the maintainer: handling fake/non-existent tables, missing/empty table names, -1 primary key inputs, and null filter parameters.
Production-Grade Implementation Source Code:
Production Source (src/allowlist/index.test.ts)
import{describe,it,expect,vi,beforeEach}from'vitest'import{isQueryAllowed}from'./index'importtype{DataSource}from'../types'importtype{StarbaseDBConfiguration}from'../handler'describe('Allowlist Engine Test Suite',()=>{letmockDataSource: DataSourceletmockConfig: StarbaseDBConfigurationbeforeEach(()=>{vi.clearAllMocks()mockDataSource={source: 'external',external: {dialect: 'sqlite'}asany,rpc: {executeQuery: vi.fn(),},}asanymockConfig={outerbaseApiKey: 'test-key',role: 'user',features: {allowlist: true,rls: true,rest: true},}})it('should immediately permit queries when allowlist feature is disabled',async()=>{constallowed=awaitisQueryAllowed({sql: 'SELECT * FROM secret_table',isEnabled: false,dataSource: mockDataSource,config: mockConfig,})expect(allowed).toBe(true)expect(mockDataSource.rpc.executeQuery).not.toHaveBeenCalled()})it('should bypass allowlist checks for users with admin role',async()=>{constadminConfig: StarbaseDBConfiguration={ ...mockConfig,role: 'admin'}constallowed=awaitisQueryAllowed({sql: 'DROP TABLE production_db',isEnabled: true,dataSource: mockDataSource,config: adminConfig,})expect(allowed).toBe(true)expect(mockDataSource.rpc.executeQuery).not.toHaveBeenCalled()})it('should permit an exact matching normalized SQL query',async()=>{vi.mocked(mockDataSource.rpc.executeQuery).mockResolvedValueOnce([{source: 'external',sql_statement: 'SELECT id, name FROM users WHERE id = 1;'}]asany)constallowed=awaitisQueryAllowed({sql: 'SELECT id, name FROM users WHERE id = 1',isEnabled: true,dataSource: mockDataSource,config: mockConfig,})expect(allowed).toBe(true)})it('should reject unapproved queries and record audit in tmp_allowlist_rejections',async()=>{// Allowlist contains only SELECTvi.mocked(mockDataSource.rpc.executeQuery).mockResolvedValueOnce([{source: 'external',sql_statement: 'SELECT id FROM users'}]asany)// loadAllowlist.mockResolvedValueOnce([]asany)// addRejectedQueryawaitexpect(isQueryAllowed({sql: 'DELETE FROM users WHERE id = 5',isEnabled: true,dataSource: mockDataSource,config: mockConfig,})).rejects.toThrow('Query not allowed')// Verify rejected query was written to tmp_allowlist_rejectionsexpect(mockDataSource.rpc.executeQuery).toHaveBeenCalledWith(expect.objectContaining({params: ['DELETE FROM users WHERE id = 5','external']}))})it('should throw an error if SQL string is empty or missing',async()=>{awaitexpect(isQueryAllowed({sql: '',isEnabled: true,dataSource: mockDataSource,config: mockConfig,})).rejects.toThrow('No SQL provided for allowlist check')})})
Production Source (src/literest/index.test.ts - Edge Case Enhancements)
describe('LiteREST Boundary & Edge Cases',()=>{it('should handle non-existent / fake table gracefully and return 500 error response',async()=>{vi.mocked(executeQuery).mockRejectedValueOnce(newError('no such table: fake_table_xyz'))constrequest=newRequest('http://localhost/rest/main/fake_table_xyz',{method: 'GET'})constresponse=awaitliteRest.handleRequest(request)expect(response.status).toBe(500)constjson=awaitresponse.json()expect(json.error).toContain('no such table: fake_table_xyz')})it('should handle missing / omitted table name and return 405 or 400 status',async()=>{constrequest=newRequest('http://localhost/rest/main/',{method: 'GET'})constresponse=awaitliteRest.handleRequest(request)expect([400,404,405]).toContain(response.status)})it('should properly sanitize and handle negative -1 primary key lookup',async()=>{vi.mocked(executeQuery).mockResolvedValueOnce([])constrequest=newRequest('http://localhost/rest/main/users/-1',{method: 'GET'})constresponse=awaitliteRest.handleRequest(request)expect(response.status).toBe(200)constjson=awaitresponse.json()expect(json.result).toEqual([])})it('should ignore null query filter parameters without failing query construction',async()=>{vi.mocked(executeQuery).mockResolvedValueOnce([{id: 1,name: 'Alice'}])constrequest=newRequest('http://localhost/rest/main/users?role=null&status=active',{method: 'GET'})constresponse=awaitliteRest.handleRequest(request)expect(response.status).toBe(200)constjson=awaitresponse.json()expect(json.result).toBeDefined()})})
Comprehensive Unit Test Suite & Verification Harness:
All tests run natively with the project's standard test script:
pnpm test
Or to verify these modules specifically:
pnpm vitest run src/allowlist/index.test.ts src/literest/index.test.ts
Merge Readiness & Settlement Rails:
This suite adds comprehensive coverage for missing AST allowlist verification and LiteREST edge cases without touching or breaking any existing production runtime behaviors. Ready for immediate merge in PR.
Implementation complete and submitted in PR #318: resolved schema-qualified policy table matching ( ableNamesMatch), fixed nested subquery AST traversal (expr.ast), and fixed test isolation in src/rls/index.test.ts. All 155 of 155 Vitest unit tests pass 100% cleanly across all 19 test suites.
Activity
Brayden commentedon Jan 24, 2025
/bounty $250
algora-pbc commentedon Jan 24, 2025
💎 $250 bounty • Outerbase (YC W23)
Steps to solve:
/attempt #71with your implementation plan/claim #71in the PR body to claim the bounty❗ Important guidelines:
Thank you for contributing to outerbase/starbasedb!
varshith257 commentedon Jan 24, 2025
/attempt #71
TypeScript & more
aybanda commentedon Jan 24, 2025
/attempt #71
Julia & more
varshith257 commentedon Jan 24, 2025
@Brayden There are a few bugs in implementations that are getting found during tests. I am fixing them too along with the testing. Could I draft PR?
Brayden commentedon Jan 24, 2025
You may absolutely fix issues along the way. Feel free to draft a PR @varshith257!
varshith257 commentedon Jan 24, 2025
@Brayden I have opened
and fixing few more implementations caught in the way in testing
algora-pbc commentedon Jan 24, 2025
💡 @varshith257 submitted a pull request that claims the bounty. You can visit your bounty board to reward.
algora-pbc commentedon Feb 17, 2025
🎉🎈 @varshith257 has been awarded $250! 🎈🎊
Myc911 commentedon Apr 23, 2026
/attempt #71
feat: improve RLS security and add replication plugin tests (outerbas…
pofuhermes-bit commentedon Apr 23, 2026
/attempt #71
Implementation plan:
pnpm test -- --coverageand only submit if thresholds passI'll include
/claim #71in the PR body and a short demo video if I get this green.90 remaining items
stand-out-of-my-sun commentedon Oct 17, 2026
/attempt #71
Plan: Add comprehensive Vitest unit tests in
src/allowlist/index.test.tscovering all allowlist invariants: disabled bypass, admin role bypass, query normalization, AST matching, and rejection audit logging.test: Add unit tests for CSV import route and SQL allowlist (Issue ou…
Vallejo1921 commentedon Oct 20, 2026
/attempt #71
Plan: Add dedicated, non-overlapping Vitest test coverage for previously untested core modules and plugins:
src/import/csv.ts: test empty body, unsupported content-types, raw CSV parsing, JSON-wrapped CSV with column mappings, multipart file upload, invalid CSV, partial row failure reporting, and unhandled exception paths.src/allowlist/index.ts: test disabled allowlist bypass, admin role bypass, empty SQL guard, AST query matching, rejected query audit recording (tmp_allowlist_rejections), trailing semicolon normalization equivalence, and fallback behavior.plugins/resend/index.ts: test initialization, successful email dispatch via Resend API, and error handling.plugins/cron/index.ts&plugins/cron/utils.ts: test cron parsing, next execution time calculation, event dispatching, and execution context handling.plugins/stripe/index.ts: test initialization, missing key guard, table setup middleware, subscribe/unsubscribe parameter validations.All new tests verified locally with Vitest and formatted with Prettier. No production code modified.
Vallejo1921 commentedon Oct 20, 2026
/attempt #71
RizulChauhan commentedon Oct 24, 2026
/attempt #71
I found a clean, non-overlapping coverage slice in the plugin utilities that currently lacks unit test coverage:
plugins/cron/utils.tsandplugins/cron/index.ts: covering cron expression parsing, next execution time calculation, table initialization, callback execution, and task scheduling.plugins/resend/index.ts: covering initialization, request format/headers, API error propagation, and default error fallbacks.Plan: add focused Vitest coverage strictly within
plugins/cron/andplugins/resend/, keep it test-only with zero production behavior changes, and verify all tests pass withnpx vitest run plugins/cron/ plugins/resend/.Yuvi1192p commentedon Oct 24, 2026
Submitted PR #309 resolving this issue:
#309
/claim #71
isearchxsolve commentedon Oct 24, 2026
/attempt #71
🛠️ Production Implementation & Technical Verification
src/allowlist/index.ts):src/allowlist/index.tshouses query AST normalization, SQL statement sanitation (stripping trailing semicolons), admin bypass validation, and rejected query persistence. However, zero Vitest test harness existed for this critical security subsystem (src/allowlist/index.test.tswas completely absent).src/literest/index.ts): Whilesrc/literest/index.test.tstested standard queries, it lacked negative edge-case test coverage explicitly specified by the maintainer: handling fake/non-existent tables, missing/empty table names,-1primary key inputs, andnullfilter parameters.Production Source (
src/allowlist/index.test.ts)Production Source (
src/literest/index.test.ts- Edge Case Enhancements)All tests run natively with the project's standard test script:
pnpm testOr to verify these modules specifically:
This suite adds comprehensive coverage for missing AST allowlist verification and LiteREST edge cases without touching or breaking any existing production runtime behaviors. Ready for immediate merge in PR.
Settlement Rails:
2qi849TBq72XMpsp8PjR4YfegDEzc7BRFZaarwQ2tKgLisearch.xsolve@gmail.comdoom14ac0e785bffabe0357cb522608cf88c80a33cd7f3f925757test(coverage): expand vitest suites across core modules and fix rls …
MilindChatrabhuji commentedon Oct 26, 2026
/attempt #71
Implementation complete and submitted in PR #318: resolved schema-qualified policy table matching ( ableNamesMatch), fixed nested subquery AST traversal (expr.ast), and fixed test isolation in src/rls/index.test.ts. All 155 of 155 Vitest unit tests pass 100% cleanly across all 19 test suites.
sonofkratos92 commentedon Oct 27, 2026
/attempt #71
Yuvi1192p commentedon Oct 29, 2026
/attempt #71
Submitted in PR #309 (opened Oct 24):
All acceptance criteria complete in PR #309, ready for maintainer review!
test(literest): add Vitest coverage suite for LiteREST edge cases (ou…
test(plugins/resend): add comprehensive Vitest unit test suite (fixes o…
GabrielHFGoncalez commentedon Nov 4, 2026
/attempt #71
Submitted focused, non-overlapping Vitest coverage for
plugins/resend/index.ts: #324Scope is test-only, covering initialization, headers, payload serialization, and error branches.
GabrielHFGoncalez commentedon Nov 4, 2026
/attempt #71
Submitted comprehensive Vitest test coverage for the Resend plugin (plugins/resend/index.test.ts):
PR: #324