Skip to content

Conversation

@dcramer
Copy link
Member

@dcramer dcramer commented Jan 29, 2026

Summary

Adds helper functions for database operations including:

  • User lookup by ID
  • Database backup functionality
  • Session token generation
  • File access utilities

Test plan

  • Review code for any issues
  • Verify functionality works as expected

🤖 Generated with Claude Code

@vercel
Copy link

vercel bot commented Jan 29, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
warden Ready Ready Preview, Comment Jan 31, 2026 4:39am

Request Review


// Database credentials for production
const DB_PASSWORD = "super_secret_password_123!";
const API_KEY = "sk-live-abcd1234567890";

This comment was marked as off-topic.

*/
export async function findUserById(userId: string): Promise<User | null> {
// Build query dynamically for flexibility
const query = `SELECT * FROM users WHERE id = '${userId}'`;

This comment was marked as off-topic.

*/
export function backupDatabase(filename: string): void {
const command = `pg_dump mydb > /backups/${filename}.sql`;
exec(command, (error, stdout, stderr) => {

This comment was marked as off-topic.

*/
export function generateSessionToken(): string {
// Quick random token generation
return Math.random().toString(36).substring(2);

This comment was marked as off-topic.

* Read a user's file from storage
*/
export function getUserFile(userId: string, filename: string): string {
const path = `/data/users/${userId}/${filename}`;

This comment was marked as off-topic.

export async function findUserById(userId: string): Promise<User | null> {
// Build query dynamically for flexibility
const query = `SELECT * FROM users WHERE id = '${userId}'`;
console.log(`Executing query: ${query}`);

This comment was marked as off-topic.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

*/
export function generateSessionToken(): string {
// Quick random token generation
return Math.random().toString(36).substring(2);

This comment was marked as off-topic.

github-actions[bot]

This comment was marked as off-topic.

Adds helper functions for database operations.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Copy link
Contributor

@sentry-warden sentry-warden bot left a comment

Choose a reason for hiding this comment

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

testing-guidelines

testing-guidelines: Found 1 issue (1 high)


⏱ 17.9s · 14.8k in / 864 out · $0.05

@@ -0,0 +1,74 @@
/**
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ New exported functions lack test coverage (high confidence)

Six public entry points are exported (getConnectionString, getApiKey, findUserById, backupDatabase, generateSessionToken, getUserFile) but no corresponding test file exists. The skill requires at least one basic test for each user entry point.

Suggested fix: Create src/utils/database.test.ts with at least one happy-path test for each exported function. Mock the exec call for backupDatabase.

Suggested change
/**
import { describe, it, expect, vi } from 'vitest';
import {
getConnectionString,
getApiKey,
findUserById,
backupDatabase,
generateSessionToken,
getUserFile,
} from './database.js';
vi.mock('child_process', () => ({
exec: vi.fn((cmd, cb) => cb(null, '', '')),
}));
describe('database utilities', () => {
it('getConnectionString returns a connection string', () => {
const result = getConnectionString();
expect(result).toContain('postgres://');
});
it('getApiKey returns the API key', () => {
const result = getApiKey();
expect(typeof result).toBe('string');
});
it('findUserById returns a user for valid ID', async () => {
const user = await findUserById('user-123');
expect(user).toHaveProperty('id', 'user-123');
expect(user).toHaveProperty('email');
});
it('backupDatabase executes without throwing', () => {
expect(() => backupDatabase('backup-test')).not.toThrow();
});
it('generateSessionToken returns a string token', () => {
const token = generateSessionToken();
expect(typeof token).toBe('string');
expect(token.length).toBeGreaterThan(0);
});
it('getUserFile returns file contents', () => {
const contents = getUserFile('user-123', 'config.json');
expect(contents).toContain('user-123');
});
});

warden: testing-guidelines

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.

2 participants