Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions backend/src/entities/table-schema/table-schema.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { ApiBearerAuth, ApiBody, ApiOperation, ApiParam, ApiQuery, ApiResponse,
import { UseCaseType } from '../../common/data-injection.tokens.js';
import { MasterPassword } from '../../decorators/master-password.decorator.js';
import { SlugUuid } from '../../decorators/slug-uuid.decorator.js';
import { Timeout, TimeoutDefaults } from '../../decorators/timeout.decorator.js';
import { UserId } from '../../decorators/user-id.decorator.js';
import {
ConnectionEditGuard,
Expand Down Expand Up @@ -78,6 +79,7 @@ export class TableSchemaController {
@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.

@Post('/table-schema/:connectionId/generate')
@HttpCode(HttpStatus.CREATED)
async generate(
Expand Down
Loading