{"record":{"id":"340ab471dcebdef6","repo":"unclecode/crawl4ai","slug":"profile-not-found-profile-name-or-path","errorCode":null,"errorMessage":"Profile not found: {profile_name_or_path}","messagePattern":"Profile not found: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"crawl4ai/browser_profiler.py","lineNumber":804,"sourceCode":"        \"\"\"\n        Shrink a profile to reduce storage while preserving authentication data.\n\n        Args:\n            profile_name_or_path: Profile name or full path\n            level: LIGHT, MEDIUM, AGGRESSIVE (default), or MINIMAL\n            dry_run: If True, only preview what would be removed\n\n        Returns:\n            Dict with 'removed', 'kept', 'bytes_freed', 'size_before', 'size_after', 'errors'\n        \"\"\"\n        # Resolve path\n        if os.path.isabs(profile_name_or_path):\n            profile_path = profile_name_or_path\n        else:\n            profile_path = os.path.join(self.profiles_dir, profile_name_or_path)\n\n        if not os.path.isdir(profile_path):\n            raise ValueError(f\"Profile not found: {profile_name_or_path}\")\n\n        result = shrink_profile(profile_path, level, dry_run)\n\n        action = \"Would free\" if dry_run else \"Freed\"\n        self.logger.info(\n            f\"{action} {_format_size(result['bytes_freed'])} \"\n            f\"({len(result['removed'])} items removed, {len(result['kept'])} kept)\",\n            tag=\"SHRINK\"\n        )\n\n        return result\n\n    async def interactive_manager(self, crawl_callback=None):\n        \"\"\"\n        Launch an interactive profile management console.\n        \n        Args:\n            crawl_callback (callable, optional): Function to call when selecting option to use ","sourceCodeStart":786,"sourceCodeEnd":822,"githubUrl":"https://github.com/unclecode/crawl4ai/blob/7e801521428ee12509994d39151006f64055ebe3/crawl4ai/browser_profiler.py#L786-L822","documentation":"BrowserProfiler.shrink_profile(profile_name_or_path) resolves the argument against profiles_dir when relative, then requires the result to be an existing directory; otherwise ValueError('Profile not found: ...'). This is the class-method counterpart to the free function's check and does handle bare profile names — failure means neither <profiles_dir>/<name> nor the absolute path is a directory.","triggerScenarios":"shrink_profile('my-profile') before the profile was ever created; typos in the profile name; profiles_dir customized so the name resolves elsewhere; passing a file path (e.g. the .zip export) instead of the directory.","commonSituations":"Automated cleanup scripts running before first profile creation; renaming profiles; moving profiles_dir via config after profiles were made.","solutions":["List existing profiles first (BrowserProfiler().list_profiles()) and use an exact name.","Pass the absolute path to the profile directory if it lives outside profiles_dir.","Create the profile (profile flow) at least once before shrinking."],"exampleFix":"# before\nprofiler.shrink_profile('my-profil', ShrinkLevel.MEDIUM)  # typo -> ValueError\n\n# after\nnames = [p['name'] for p in profiler.list_profiles()]\nassert 'my-profile' in names\nprofiler.shrink_profile('my-profile', ShrinkLevel.MEDIUM)","handlingStrategy":"validation","validationCode":"import os\npath = p if os.path.isabs(p) else os.path.join(profiler.profiles_dir, p)\nif not os.path.isdir(path):\n    raise ValueError(f'no such profile: {p} (searched {path})')","typeGuard":"import os\ndef profile_exists(profiler, name_or_path) -> bool:\n    path = name_or_path if os.path.isabs(name_or_path) else os.path.join(profiler.profiles_dir, name_or_path)\n    return os.path.isdir(path)","tryCatchPattern":"try:\n    result = profiler.shrink_profile(name, level)\nexcept ValueError as e:\n    if 'Profile not found' in str(e):\n        name = pick_from(profiler.list_profiles())  # correct the name interactively\n        result = profiler.shrink_profile(name, level)\n    else:\n        raise","preventionTips":["List profiles and validate the name before shrinking.","Pass absolute paths for profiles outside profiles_dir.","Run shrink only after a profile has been created."],"tags":["browser-profiler","validation","filesystem"],"backgroundTag":null,"analyzedSha":"7e801521428ee12509994d39151006f64055ebe3","analyzedAt":"2026-08-14T20:46:20.673Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}