{"record":{"id":"265beef1632a3c9a","repo":"feder-cr/Jobs_Applier_AI_Agent_AIHawk","slug":"errore-durante-la-lettura-del-file-css-e","errorCode":null,"errorMessage":"Errore durante la lettura del file CSS: {e}","messagePattern":"Errore durante la lettura del file CSS: (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"src/libs/resume_and_cover_builder/resume_generator.py","lineNumber":34,"sourceCode":"    \n    def set_resume_object(self, resume_object):\n         self.resume_object = resume_object\n         \n\n    def _create_resume(self, gpt_answerer: Any, style_path):\n        # Imposta il resume nell'oggetto gpt_answerer\n        gpt_answerer.set_resume(self.resume_object)\n        \n        # Leggi il template HTML\n        template = Template(global_config.html_template)\n        \n        try:\n            with open(style_path, \"r\") as f:\n                style_css = f.read()  # Correzione: chiama il metodo `read` con le parentesi\n        except FileNotFoundError:\n            raise ValueError(f\"Il file di stile non è stato trovato nel percorso: {style_path}\")\n        except Exception as e:\n            raise RuntimeError(f\"Errore durante la lettura del file CSS: {e}\")\n        \n        # Genera l'HTML del resume\n        body_html = gpt_answerer.generate_html_resume()\n        \n        # Applica i contenuti al template\n        return template.substitute(body=body_html, style_css=style_css)\n\n    def create_resume(self, style_path):\n        strings = load_module(global_config.STRINGS_MODULE_RESUME_PATH, global_config.STRINGS_MODULE_NAME)\n        gpt_answerer = LLMResumer(global_config.API_KEY, strings)\n        return self._create_resume(gpt_answerer, style_path)\n\n    def create_resume_job_description_text(self, style_path: str, job_description_text: str):\n        strings = load_module(global_config.STRINGS_MODULE_RESUME_JOB_DESCRIPTION_PATH, global_config.STRINGS_MODULE_NAME)\n        gpt_answerer = LLMResumeJobDescription(global_config.API_KEY, strings)\n        gpt_answerer.set_job_description_from_text(job_description_text)\n        return self._create_resume(gpt_answerer, style_path)\n","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/feder-cr/Jobs_Applier_AI_Agent_AIHawk/blob/79155b52faccfbd19b834680af285eac70dd2df4/src/libs/resume_and_cover_builder/resume_generator.py#L16-L52","documentation":"While reading the style CSS in _create_resume, any non-FileNotFoundError raised by open()/read() (e.g. PermissionError, IsADirectoryError, UnicodeDecodeError) is wrapped in a RuntimeError with the Italian message 'Errore durante la lettura del file CSS: ...' (error while reading the CSS file), chaining the original exception.","triggerScenarios":"The style path exists but cannot be read as text: no read permission, the path is a directory, or the CSS contains bytes that fail UTF-8 decoding.","commonSituations":"Restrictive file permissions (root-owned style files), pointing style_path at a directory by mistake, or CSS saved in a non-UTF-8 encoding.","solutions":["Inspect the chained original exception (__cause__) to identify the real I/O problem.","Fix permissions (chmod/chown) on the CSS file, or point style_path at an actual file.","Re-save the CSS as UTF-8 if decoding failed."],"exampleFix":"# before\nstyle_path = '/etc/private/style.css'  # PermissionError -> RuntimeError\n# after\nimport os, stat\nos.chmod(style_path, stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH)  # ensure readable\nhtml = generator.create_resume(style_path)","handlingStrategy":"try-catch","validationCode":"import os\nif not os.access(style_path, os.R_OK) or not os.path.isfile(style_path):\n    raise OSError(f'style not readable: {style_path}')","typeGuard":null,"tryCatchPattern":"try:\n    html = generator.create_resume(style_path)\nexcept RuntimeError as e:\n    root = e.__cause__  # real IOError (permissions, encoding, ...)\n    logger.error('CSS read failed: %s', root)\n    html = generator.create_resume(str(DEFAULT_STYLE_PATH))","preventionTips":["Always inspect __cause__ on wrapped RuntimeError to find the underlying I/O problem.","Store style files as UTF-8 with permissive read permissions next to the app."],"tags":["python","file-io","permissions","css","encoding"],"backgroundTag":"file-read-failed","analyzedSha":"79155b52faccfbd19b834680af285eac70dd2df4","analyzedAt":"2026-08-28T14:10:26.659Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}