Skip to content

Commit f5ec923

Browse files
authored
fix: assert directory for get_file (#802)
# Motivation <!-- Why is this change necessary? --> # Content <!-- Please include a summary of the change --> # Testing <!-- How was the change tested? --> # Please check the following before marking your PR as ready for review - [ ] I have added tests for my changes - [ ] I have updated the documentation or added new documentation as needed
1 parent ef4fbdf commit f5ec923

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/codegen/sdk/codebase/codebase_context.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -609,6 +609,12 @@ def get_edges(self) -> list[tuple[NodeId, NodeId, EdgeType, Usage | None]]:
609609
return [(x[0], x[1], x[2].type, x[2].usage) for x in self._graph.weighted_edge_list()]
610610

611611
def get_file(self, file_path: os.PathLike, ignore_case: bool = False) -> SourceFile | None:
612+
# If not part of repo path, return None
613+
absolute_path = self.to_absolute(file_path)
614+
if not self.is_subdir(absolute_path):
615+
assert False, f"File {file_path} is not part of the repository path"
616+
617+
# Check if file exists in graph
612618
node_id = self.filepath_idx.get(str(self.to_relative(file_path)), None)
613619
if node_id is not None:
614620
return self.get_node(node_id)

0 commit comments

Comments
 (0)