fix: add user id checks

This commit is contained in:
Rohit Rajan
2025-12-08 11:35:14 +05:30
parent 9cd2cfd729
commit c87edcc462
3 changed files with 17 additions and 5 deletions

View File

@@ -60,9 +60,11 @@ router.post("/sdk/robots", requireAPIKey, async (req: AuthenticatedRequest, res:
}); });
} }
} else { } else {
const enrichResult = await WorkflowEnricher.enrichWorkflow(workflowFile.workflow); const enrichResult = await WorkflowEnricher.enrichWorkflow(workflowFile.workflow, user.id);
if (!enrichResult.success) { if (!enrichResult.success) {
logger.error("[SDK] Error in Selector Validation:\n" + JSON.stringify(enrichResult.errors, null, 2))
return res.status(400).json({ return res.status(400).json({
error: "Workflow validation failed", error: "Workflow validation failed",
details: enrichResult.errors details: enrichResult.errors
@@ -640,7 +642,7 @@ router.post("/sdk/robots/:id/runs/:runId/abort", requireAPIKey, async (req: Auth
*/ */
router.post("/sdk/extract/llm", requireAPIKey, async (req: AuthenticatedRequest, res: Response) => { router.post("/sdk/extract/llm", requireAPIKey, async (req: AuthenticatedRequest, res: Response) => {
try { try {
const user = req.user.id const user = req.user
const { url, prompt, llmProvider, llmModel, llmApiKey, llmBaseUrl, robotName } = req.body; const { url, prompt, llmProvider, llmModel, llmApiKey, llmBaseUrl, robotName } = req.body;
if (!url || !prompt) { if (!url || !prompt) {
@@ -654,7 +656,7 @@ router.post("/sdk/extract/llm", requireAPIKey, async (req: AuthenticatedRequest,
model: llmModel, model: llmModel,
apiKey: llmApiKey, apiKey: llmApiKey,
baseUrl: llmBaseUrl baseUrl: llmBaseUrl
}); }, user.id);
if (!workflowResult.success || !workflowResult.workflow) { if (!workflowResult.success || !workflowResult.workflow) {
return res.status(400).json({ return res.status(400).json({

View File

@@ -34,7 +34,17 @@ export class SelectorValidator {
*/ */
async initialize(page: Page, url: string): Promise<void> { async initialize(page: Page, url: string): Promise<void> {
this.page = page; this.page = page;
await this.page.goto(url, { waitUntil: 'networkidle', timeout: 30000 }); try {
await page.goto(url, {
waitUntil: "networkidle",
timeout: 100000,
});
} catch (err) {
await page.goto(url, {
waitUntil: "domcontentloaded",
timeout: 100000,
});
}
logger.info(`Navigated to ${url} using RemoteBrowser page`); logger.info(`Navigated to ${url} using RemoteBrowser page`);
} }

View File

@@ -33,7 +33,7 @@ export class WorkflowEnricher {
*/ */
static async enrichWorkflow( static async enrichWorkflow(
simplifiedWorkflow: SimplifiedWorkflowPair[], simplifiedWorkflow: SimplifiedWorkflowPair[],
userId: string = 'sdk-validation-user' userId: string
): Promise<{ success: boolean; workflow?: any[]; errors?: string[]; url?: string }> { ): Promise<{ success: boolean; workflow?: any[]; errors?: string[]; url?: string }> {
const errors: string[] = []; const errors: string[] = [];
const enrichedWorkflow: any[] = []; const enrichedWorkflow: any[] = [];