Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Claude finished @omar-inkeep's task —— View job PR Review: Fix OAuth Set Credential IDTodo List:
Review SummaryThis PR correctly addresses an inconsistency where credential IDs were using raw tool names instead of the standardized ✅ Positive Changes1. Data Integrity & Consistency
2. Security Improvement
3. Database Constraint Compliance
🚨 Critical Concerns1. Potential Breaking Change for Existing Data
2. Missing Database Migration pnpm db:generate # Generate migration from schema changes
pnpm db:migrate # Apply migration to databaseHowever, this appears to be a code change rather than schema change, but existing data compatibility should still be considered. 🔍 Implementation AnalysisLocations Changed (agents-manage-api/src/routes/oauth.ts):
Function Implementation (packages/agents-core/src/validation/id-validation.ts:27-49): export function generateIdFromName(name: string): string {
const id = name
.toLowerCase()
.replace(/[^a-z0-9_-]+/g, '-') // Replace invalid chars with hyphens
.replace(/^-+|-+$/g, '') // Remove leading/trailing hyphens
.replace(/-{2,}/g, '-'); // Replace multiple consecutive hyphens with single hyphen
// ... validation and truncation logic
}📊 Risk Assessment & RecommendationsImmediate Actions Required:
Suggested Migration Strategy: // In findOrCreateCredential, try both IDs:
try {
const existingCredential = await getCredentialReferenceWithTools(dbClient)({
scopes: { tenantId, projectId },
id: generateIdFromName(originalToolName), // New normalized ID
});
if (existingCredential) return existingCredential;
// Fallback to original ID for backward compatibility
return await getCredentialReferenceWithTools(dbClient)({
scopes: { tenantId, projectId },
id: originalToolName,
});
} catch {
// Continue with creation...
}🧪 Testing GapsMissing Test Coverage:
Recommended Test Cases: describe('OAuth credential ID generation', () => {
it('should handle tool names with spaces and special characters', async () => {
// Test with "My OAuth Tool!" -> "my-oauth-tool"
});
it('should maintain backward compatibility with existing credentials', async () => {
// Test lookup of credentials created before this change
});
});🎯 Final RecommendationApprove with Required Changes: This fix is necessary and follows established patterns, but needs additional safeguards for existing data. Priority Actions:
The core change is correct and improves system consistency, but the implementation needs to account for existing data to prevent service disruption. |
should use generateIdFromName