feat: add timeout decorator to generate schema change endpoint#1748
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a request timeout to the “generate schema change” endpoint to prevent long-running AI-backed operations from hanging indefinitely.
Changes:
- Import
Timeout/TimeoutDefaultsintoTableSchemaController. - Apply
@Timeout(TimeoutDefaults.AI)toPOST /table-schema/:connectionId/generate.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
📝 WalkthroughWalkthroughA timeout decorator has been imported and applied to the Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
🚥 Pre-merge checks | ✅ 6✅ Passed checks (6 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Review rate limit: 0/1 reviews remaining, refill in 60 minutes.Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@backend/src/entities/table-schema/table-schema.controller.ts`:
- Line 82: Replace the hardcoded decorator `@Timeout`(TimeoutDefaults.AI) with an
env-aware expression like the pattern used in user-ai-requests-v2.controller.ts
so tests get the longer timeout; specifically change the `@Timeout` argument to
use process.env.NODE_ENV !== 'test' ? TimeoutDefaults.AI :
TimeoutDefaults.AI_TEST (keeping the decorator `@Timeout` and the TimeoutDefaults
constants) so AI operations use TimeoutDefaults.AI in non-test environments and
TimeoutDefaults.AI_TEST during tests.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: c1c32383-592c-4a5f-b093-c795f792f177
📒 Files selected for processing (1)
backend/src/entities/table-schema/table-schema.controller.ts
| @ApiBody({ type: GenerateSchemaChangeDto }) | ||
| @ApiResponse({ status: 201, type: SchemaChangeBatchResponseDto }) | ||
| @UseGuards(ConnectionEditGuard) | ||
| @Timeout(TimeoutDefaults.AI) |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
# First, let's check the controller file and understand the context around line 82
cat -n backend/src/entities/table-schema/table-schema.controller.ts | head -100Repository: rocket-admin/rocketadmin
Length of output: 4929
🏁 Script executed:
# Find the Timeout decorator implementation
find . -type f -name "*.ts" | xargs rg "@Timeout|TimeoutDefaults" -l | head -20Repository: rocket-admin/rocketadmin
Length of output: 1388
🏁 Script executed:
# Search for TimeoutDefaults enum definition
rg "enum TimeoutDefaults|const TimeoutDefaults" -A 10Repository: rocket-admin/rocketadmin
Length of output: 890
🏁 Script executed:
cat -n backend/src/interceptors/timeout.interceptor.tsRepository: rocket-admin/rocketadmin
Length of output: 1582
🏁 Script executed:
# Also search for how other routes handle timeouts to see the pattern
rg "@Timeout" backend/src/entities -B 2 | head -80Repository: rocket-admin/rocketadmin
Length of output: 5284
🏁 Script executed:
# Check if there are test configuration files that override timeouts
fd -e spec.ts -e test.ts backend/src/entities/table-schema/ | head -5Repository: rocket-admin/rocketadmin
Length of output: 510
🏁 Script executed:
# Search for any environment-aware timeout logic or test setup
rg "NODE_ENV.*test|AI_TEST" backend/src --type ts | grep -i timeoutRepository: rocket-admin/rocketadmin
Length of output: 589
🏁 Script executed:
# Check if there's any pattern in how AI operations handle timeouts differently
rg "TimeoutDefaults.AI" -B 5 -A 1 backend/src | head -60Repository: rocket-admin/rocketadmin
Length of output: 3884
Use env-aware timeout for this AI operation to allow longer timeout in test runs.
@Timeout(TimeoutDefaults.AI) bypasses the interceptor's env-aware fallback and caps this route at 5 minutes in both production and test. AI operations elsewhere in the codebase (e.g., user-ai-requests-v2.controller.ts) correctly use @Timeout(process.env.NODE_ENV !== 'test' ? TimeoutDefaults.AI : TimeoutDefaults.AI_TEST) to allow 10 minutes in tests. Update this to follow the same pattern.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@backend/src/entities/table-schema/table-schema.controller.ts` at line 82,
Replace the hardcoded decorator `@Timeout`(TimeoutDefaults.AI) with an env-aware
expression like the pattern used in user-ai-requests-v2.controller.ts so tests
get the longer timeout; specifically change the `@Timeout` argument to use
process.env.NODE_ENV !== 'test' ? TimeoutDefaults.AI : TimeoutDefaults.AI_TEST
(keeping the decorator `@Timeout` and the TimeoutDefaults constants) so AI
operations use TimeoutDefaults.AI in non-test environments and
TimeoutDefaults.AI_TEST during tests.
Summary by CodeRabbit