Skip to content

Bug: Project lookup fails without permalink normalization in deps.py #347

@jope-bm

Description

@jope-bm

Summary

Project lookups in the dependency injection functions get_project_config() and get_project_id() were failing when project names contained characters that needed permalink normalization (e.g., spaces, special characters).

Problem

The get_project_config() and get_project_id() functions in src/basic_memory/deps.py were directly passing project names to project_repository.get_by_permalink() without first converting them to permalinks using generate_permalink().

This caused lookups to fail for projects with names containing:

  • Spaces
  • Special characters
  • Capital letters that should be normalized

Root Cause

Location: src/basic_memory/deps.py:61-68 and src/basic_memory/deps.py:147-154

The code was doing:

project_obj = await project_repository.get_by_permalink(str(project))

Instead of:

project_permalink = generate_permalink(str(project))
project_obj = await project_repository.get_by_permalink(project_permalink)

Solution

Added permalink normalization before database lookups in both functions:

  1. Import generate_permalink from basic_memory.utils
  2. Convert project name to permalink before lookup
  3. Use normalized permalink for database query

Impact

This bug would have caused:

  • 404 errors when accessing projects via API with non-normalized names
  • Inconsistent behavior between different project name formats
  • Failed project resolution in dependency injection chain

Related

Similar to the fix in #345 for project deletion with permalink normalization.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions