feder-cr/Jobs_Applier_AI_Agent_AIHawk · error · ValueError
dir path cannot be None
Error message
dir path cannot be None
What it means
save_file copies an artifact (resume/CV) into dir_path using shutil.copy; it rejects a None dir_path up front because shutil.copy(None, ...) would raise a confusing TypeError. It is a defensive guard against calling the copy helper without a valid destination directory.
Source
Thrown at src/job_application_saver.py:52
# Function to save the job application details as a JSON file
def save_application_details(self):
if self.job_application_files_path is None:
raise ValueError(
"Job application file path is not set. Please create the application directory first."
)
json_file_path = os.path.join(
self.job_application_files_path, "job_application.json"
)
with open(json_file_path, "w") as json_file:
json.dump(self.job_application.application, json_file, indent=4)
# Function to save files like Resume and CV
def save_file(self, dir_path, file_path, new_filename):
if dir_path is None:
raise ValueError("dir path cannot be None")
# Copy the file to the application directory with a new name
destination = os.path.join(dir_path, new_filename)
shutil.copy(file_path, destination)
# Function to save job description as a text file
def save_job_description(self):
if self.job_application_files_path is None:
raise ValueError(
"Job application file path is not set. Please create the application directory first."
)
job: Job = self.job_application.job
json_file_path = os.path.join(
self.job_application_files_path, "job_description.json"
)
with open(json_file_path, "w") as json_file:View on GitHub (pinned to 79155b52fa)
Solutions
- Ensure the application directory exists and a real path is passed: create the directory first, then call save_file with that path.
- If dir_path is derived from job_application_files_path, fix the root cause (missing create-directory call) rather than catching the ValueError.
- Guard callers with a None check and skip or queue the file copy with a warning.
Example fix
// before saver.save_file(None, resume_path, 'resume.pdf') // after dir_path = saver.job_application_files_path or saver.create_application_directory() saver.save_file(dir_path, resume_path, 'resume.pdf')
Defensive patterns
Strategy: type-guard
Validate before calling
assert dir_path is not None and os.path.isdir(dir_path), 'dir_path must be an existing directory' saver.save_file(dir_path, file_path, new_filename)
Type guard
def is_valid_dir(p) -> bool:
return p is not None and isinstance(p, str) and os.path.isdir(p) Try / catch
try:
saver.save_file(dir_path, file_path, name)
except ValueError:
logger.warning('Skipping file copy: no application directory') Prevention
- Derive dir_path from job_application_files_path only after directory creation succeeded.
- Never pass through optional paths; normalize them to a guaranteed string first.
When it happens
Trigger: Calling save_file(None, file_path, new_filename) directly, or from save() when the application directory was never created (job_application_files_path is None is passed through as dir_path).
Common situations: Same ordering bug as error 0: the save pipeline runs before directory creation, or dir_path comes from a function that returned None on failure.
Related errors
- Job application file path is not set. Please create the appl
- Errore durante la lettura del file CSS: {e}
- Unsupported model type: {llm_model_type}
- Could not extract section name from the response.
- Section '{section_name}' not found in either resume or job_a
AI-assisted analysis of feder-cr/Jobs_Applier_AI_Agent_AIHawk@79155b52fa (2026-08-28).
Data as JSON: /api/errors/0df99477c6d5c1ba.
Report an issue: GitHub.