{"record":{"id":"55a32e7d0203cd77","repo":"unclecode/crawl4ai","slug":"invalid-wait-for-parameter-wait-for-it-shoul","errorCode":null,"errorMessage":"Invalid wait_for parameter: '{wait_for}'. It should be either a valid CSS selector, a JavaScript function, or explicitly prefixed with 'js:' or 'css:'.","messagePattern":"Invalid wait_for parameter: '(.+?)'\\. It should be either a valid CSS selector, a JavaScript function, or explicitly prefixed with 'js:' or 'css:'\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"warning","filePath":"crawl4ai/async_crawler_strategy.py","lineNumber":292,"sourceCode":"                return await self.csp_compliant_wait(page, wait_for, timeout)\n            else:\n                # Assume it's a CSS selector first\n                try:\n                    await page.wait_for_selector(wait_for, timeout=timeout)\n                except Error as e:\n                    if \"Timeout\" in str(e):\n                        raise TimeoutError(\n                            f\"Timeout after {timeout}ms waiting for selector '{wait_for}'\"\n                        )\n                    else:\n                        # If it's not a timeout error, it might be an invalid selector\n                        # Let's try to evaluate it as a JavaScript function as a fallback\n                        try:\n                            return await self.csp_compliant_wait(\n                                page, f\"() => {{{wait_for}}}\", timeout\n                            )\n                        except Error:\n                            raise ValueError(\n                                f\"Invalid wait_for parameter: '{wait_for}'. \"\n                                \"It should be either a valid CSS selector, a JavaScript function, \"\n                                \"or explicitly prefixed with 'js:' or 'css:'.\"\n                            )\n\n    async def csp_compliant_wait(\n        self, page: Page, user_wait_function: str, timeout: float = 30000\n    ):\n        \"\"\"\n        Wait for a condition in a CSP-compliant way.\n\n        Args:\n            page: Playwright page object\n            user_wait_function: JavaScript function as string that returns boolean\n            timeout: Maximum time to wait in milliseconds\n\n        Returns:\n            bool: True if condition was met, False if timed out","sourceCodeStart":274,"sourceCodeEnd":310,"githubUrl":"https://github.com/unclecode/crawl4ai/blob/7e801521428ee12509994d39151006f64055ebe3/crawl4ai/async_crawler_strategy.py#L274-L310","documentation":"ArtifactNotFound raised when a path for the id exists but lstat shows it is not a regular file — i.e. a symlink or device node sits where the artifact should be. The store is written with O_EXCL|O_NOFOLLOW and 0o600, so this state indicates tampering or filesystem corruption, and it is deliberately indistinguishable from a missing artifact.","triggerScenarios":"Someone replaces an artifact file in the store directory with a symlink (or the volume is corrupted); resolve_artifact lstats the candidate path, sees a non-regular mode, and raises ArtifactNotFound.","commonSituations":"A mounted volume with pre-existing symlinked files; an operator or another process 'organizing' the artifact dir; container image layers introducing links into the store path.","solutions":["Inspect the artifact directory and remove symlinks/special files — only regular files created by write_artifact belong there","Ensure ARTIFACT_DIR points to a directory the server exclusively owns (not shared with other tooling)","Regenerate the artifact via the crawl API; do not hand-place files into the store"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"# preflight: ensure the store contains only regular files\nimport os, stat\ndef store_is_clean(artifact_dir):\n    return all(stat.S_ISREG(e.stat(follow_symlinks=False).st_mode)\n               for e in os.scandir(artifact_dir))","typeGuard":null,"tryCatchPattern":"try:\n    path, mime = resolve_artifact(artifact_id)\nexcept ArtifactNotFound:\n    audit_store_for_symlinks(ARTIFACT_DIR)  # surface tampering to ops\n    raise","preventionTips":["Give the artifact directory exclusively to the server process","Never hand-place or link files into the store","Alert on this pattern in prod: a non-regular file may indicate tampering"],"tags":["artifacts","not-found","symlink","security"],"backgroundTag":null,"analyzedSha":"7e801521428ee12509994d39151006f64055ebe3","analyzedAt":"2026-08-14T20:46:20.673Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}