feder-cr/Jobs_Applier_AI_Agent_AIHawk · error · RuntimeError
Errore durante la lettura del file CSS: {e}
Error message
Errore durante la lettura del file CSS: {e} What it means
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.
Source
Thrown at src/libs/resume_and_cover_builder/resume_generator.py:34
def set_resume_object(self, resume_object):
self.resume_object = resume_object
def _create_resume(self, gpt_answerer: Any, style_path):
# Imposta il resume nell'oggetto gpt_answerer
gpt_answerer.set_resume(self.resume_object)
# Leggi il template HTML
template = Template(global_config.html_template)
try:
with open(style_path, "r") as f:
style_css = f.read() # Correzione: chiama il metodo `read` con le parentesi
except FileNotFoundError:
raise ValueError(f"Il file di stile non è stato trovato nel percorso: {style_path}")
except Exception as e:
raise RuntimeError(f"Errore durante la lettura del file CSS: {e}")
# Genera l'HTML del resume
body_html = gpt_answerer.generate_html_resume()
# Applica i contenuti al template
return template.substitute(body=body_html, style_css=style_css)
def create_resume(self, style_path):
strings = load_module(global_config.STRINGS_MODULE_RESUME_PATH, global_config.STRINGS_MODULE_NAME)
gpt_answerer = LLMResumer(global_config.API_KEY, strings)
return self._create_resume(gpt_answerer, style_path)
def create_resume_job_description_text(self, style_path: str, job_description_text: str):
strings = load_module(global_config.STRINGS_MODULE_RESUME_JOB_DESCRIPTION_PATH, global_config.STRINGS_MODULE_NAME)
gpt_answerer = LLMResumeJobDescription(global_config.API_KEY, strings)
gpt_answerer.set_job_description_from_text(job_description_text)
return self._create_resume(gpt_answerer, style_path)
View on GitHub (pinned to 79155b52fa)
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.
Example fix
# before style_path = '/etc/private/style.css' # PermissionError -> RuntimeError # after import os, stat os.chmod(style_path, stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH) # ensure readable html = generator.create_resume(style_path)
Defensive patterns
Strategy: try-catch
Validate before calling
import os
if not os.access(style_path, os.R_OK) or not os.path.isfile(style_path):
raise OSError(f'style not readable: {style_path}') Try / catch
try:
html = generator.create_resume(style_path)
except RuntimeError as e:
root = e.__cause__ # real IOError (permissions, encoding, ...)
logger.error('CSS read failed: %s', root)
html = generator.create_resume(str(DEFAULT_STYLE_PATH)) Prevention
- 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.
When it happens
Trigger: 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.
Common situations: Restrictive file permissions (root-owned style files), pointing style_path at a directory by mistake, or CSS saved in a non-UTF-8 encoding.
Related errors
- Job application file path is not set. Please create the appl
- dir path cannot be None
- Il file di stile non è stato trovato nel percorso: {style_pa
- An unexpected error occurred while parsing the YAML file.
- Unsupported model type: {llm_model_type}
AI-assisted analysis of feder-cr/Jobs_Applier_AI_Agent_AIHawk@79155b52fa (2026-08-28).
Data as JSON: /api/errors/265beef1632a3c9a.
Report an issue: GitHub.