Skip to content

feat: add timeout decorator to generate schema change endpoint#1748

Merged
Artuomka merged 1 commit into
mainfrom
backend_table_schema
Apr 29, 2026
Merged

feat: add timeout decorator to generate schema change endpoint#1748
Artuomka merged 1 commit into
mainfrom
backend_table_schema

Conversation

@Artuomka
Copy link
Copy Markdown
Collaborator

@Artuomka Artuomka commented Apr 29, 2026

Summary by CodeRabbit

  • Chores
    • Implemented timeout constraints on request handlers to improve system reliability and prevent indefinitely running operations.

Copilot AI review requested due to automatic review settings April 29, 2026 13:29
@Artuomka Artuomka enabled auto-merge April 29, 2026 13:29
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 / TimeoutDefaults into TableSchemaController.
  • Apply @Timeout(TimeoutDefaults.AI) to POST /table-schema/:connectionId/generate.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 29, 2026

📝 Walkthrough

Walkthrough

A timeout decorator has been imported and applied to the generate route handler in the table schema controller. The decorator constrains the handler's execution time using a predefined AI-specific timeout configuration.

Changes

Cohort / File(s) Summary
Timeout Decorator Addition
backend/src/entities/table-schema/table-schema.controller.ts
Imported timeout decorator and applied @Timeout(TimeoutDefaults.AI) to the generate route handler to enforce execution time constraints.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 A timeout hops in, swift and true,
To keep our AI routes on cue,
No endless waits, just steady pace,
With decorators adding grace! ✨⏰

🚥 Pre-merge checks | ✅ 6
✅ Passed checks (6 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: adding a timeout decorator to the generate schema endpoint.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Security Check ✅ Passed The pull request enhances security by adding DoS protection to the resource-intensive AI schema generation endpoint with a 5-minute timeout, properly implementing OWASP best practices.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch backend_table_schema

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.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 60 minutes.

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between 85b43b0 and 8615831.

📒 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)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 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 -100

Repository: 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 -20

Repository: rocket-admin/rocketadmin

Length of output: 1388


🏁 Script executed:

# Search for TimeoutDefaults enum definition
rg "enum TimeoutDefaults|const TimeoutDefaults" -A 10

Repository: rocket-admin/rocketadmin

Length of output: 890


🏁 Script executed:

cat -n backend/src/interceptors/timeout.interceptor.ts

Repository: 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 -80

Repository: 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 -5

Repository: 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 timeout

Repository: 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 -60

Repository: 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.

@Artuomka Artuomka merged commit 45bdcb6 into main Apr 29, 2026
22 of 23 checks passed
@Artuomka Artuomka deleted the backend_table_schema branch April 29, 2026 13:40
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