{"record":{"id":"0df99477c6d5c1ba","repo":"feder-cr/Jobs_Applier_AI_Agent_AIHawk","slug":"dir-path-cannot-be-none","errorCode":null,"errorMessage":"dir path cannot be None","messagePattern":"dir path cannot be None","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/job_application_saver.py","lineNumber":52,"sourceCode":"\n    # Function to save the job application details as a JSON file\n    def save_application_details(self):\n\n        if self.job_application_files_path is None:\n            raise ValueError(\n                \"Job application file path is not set. Please create the application directory first.\"\n            )\n\n        json_file_path = os.path.join(\n            self.job_application_files_path, \"job_application.json\"\n        )\n        with open(json_file_path, \"w\") as json_file:\n            json.dump(self.job_application.application, json_file, indent=4)\n\n    # Function to save files like Resume and CV\n    def save_file(self, dir_path, file_path, new_filename):\n        if dir_path is None:\n            raise ValueError(\"dir path cannot be None\")\n\n        # Copy the file to the application directory with a new name\n        destination = os.path.join(dir_path, new_filename)\n        shutil.copy(file_path, destination)\n\n    # Function to save job description as a text file\n    def save_job_description(self):\n        if self.job_application_files_path is None:\n            raise ValueError(\n                \"Job application file path is not set. Please create the application directory first.\"\n            )\n\n        job: Job = self.job_application.job\n\n        json_file_path = os.path.join(\n            self.job_application_files_path, \"job_description.json\"\n        )\n        with open(json_file_path, \"w\") as json_file:","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/feder-cr/Jobs_Applier_AI_Agent_AIHawk/blob/79155b52faccfbd19b834680af285eac70dd2df4/src/job_application_saver.py#L34-L70","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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."],"exampleFix":"// before\nsaver.save_file(None, resume_path, 'resume.pdf')\n// after\ndir_path = saver.job_application_files_path or saver.create_application_directory()\nsaver.save_file(dir_path, resume_path, 'resume.pdf')","handlingStrategy":"type-guard","validationCode":"assert dir_path is not None and os.path.isdir(dir_path), 'dir_path must be an existing directory'\nsaver.save_file(dir_path, file_path, new_filename)","typeGuard":"def is_valid_dir(p) -> bool:\n    return p is not None and isinstance(p, str) and os.path.isdir(p)","tryCatchPattern":"try:\n    saver.save_file(dir_path, file_path, name)\nexcept ValueError:\n    logger.warning('Skipping file copy: no application directory')","preventionTips":["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."],"tags":["python","none-argument","file-io","shutil"],"backgroundTag":"none-argument-passed","analyzedSha":"79155b52faccfbd19b834680af285eac70dd2df4","analyzedAt":"2026-08-28T14:10:26.659Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}