Skip to content

LocalFileIdentifiableStore.__len__ counts all directory entries, not just .json store files #503

@zrgt

Description

@zrgt

Summary

Severity: Medium
File: sdk/basyx/aas/backend/local_file.py:153

Description

__len__ returns the count of all entries in the store directory, including non-JSON files, hidden files (.DS_Store), and subdirectories.

def __len__(self) -> int:
    return len(os.listdir(self.directory_path))

Callers expecting len(store) == number_of_aas_objects get incorrect results whenever the directory contains anything other than {hash}.json files.

Fix

return sum(1 for f in os.listdir(self.directory_path) if f.endswith(".json"))

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingsdkSomething to do with the `sdk` package

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions