Skip to content

fix: remove hardcoded src prefix from package imports#115

Merged
fgogolli merged 1 commit into
mainfrom
fix/package-import-paths
Jan 21, 2026
Merged

fix: remove hardcoded src prefix from package imports#115
fgogolli merged 1 commit into
mainfrom
fix/package-import-paths

Conversation

@fgogolli

Copy link
Copy Markdown
Contributor

Description

Fixes hardcoded 'src.' prefix in package import paths that caused CLI failures when the package is installed via pip.

The handler discovery and dependency resolver were using hardcoded string literals like 'src.application', 'src.domain', 'src.infrastructure' which don't exist in the installed package structure. When installed via pip, modules are at top-level (application/, domain/, infrastructure/) not under src/.

This caused the CLI to fail with 'No matches found for pattern: src' when running commands like orb templates list from an installed package.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)

Related Issues

Fixes the CLI import errors discovered during TestPyPI testing.

How Has This Been Tested?

  • Manual testing performed
    • Built package with make build-with-version
    • Installed in clean virtualenv: pip install dist/orb_py-*.whl
    • Verified CLI works: orb --help and orb templates list
    • Confirmed handler discovery succeeds without 'src' pattern errors

Test Configuration

  • Python version: 3.12
  • OS: macOS
  • AWS region: N/A (local testing)
  • Dependencies changed: None

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published

Additional Notes

This is a minimal, surgical fix that only changes 3 hardcoded string literals used for dynamic module discovery. All actual import statements in the codebase already use the correct pattern (without 'src.' prefix).

Analysis document included at docs/research/package-structure-analysis.md for future reference on package structure alignment with Python standards.

Performance Impact

  • No significant performance impact

Security Considerations

  • No security implications

Dependencies

None

Files Changed

  • src/infrastructure/di/handler_discovery.py: Changed default base_package from 'src.application' to 'application' (2 locations)
  • src/infrastructure/di/components/dependency_resolver.py: Removed 'src.' prefix from fallback import locations
  • docs/research/package-structure-analysis.md: Added analysis document (new file)

The handler discovery and dependency resolver were using hardcoded
'src.application', 'src.domain', 'src.infrastructure' paths which
don't exist when the package is installed via pip.

When installed, the package structure is:
- application/ (not src.application)
- domain/
- infrastructure/

This caused handler discovery to fail with 'No matches found for
pattern: src' when running the CLI from an installed package.

Changes:
- HandlerDiscoveryService: Changed default base_package from
  'src.application' to 'application' (line 96)
- HandlerDiscoveryService: Fixed fallback discovery path (line 339)
- DependencyResolver: Removed 'src.' prefix from fallback import
  locations (lines 356-358)

Fixes CLI import errors when package is installed via pip install.
@fgogolli
fgogolli force-pushed the fix/package-import-paths branch from 336c01e to 25a93e3 Compare January 21, 2026 13:47
@github-actions

Copy link
Copy Markdown
Contributor

Test Results Summary

1 219 tests  ±0   781 ✅ ±0   53s ⏱️ ±0s
    1 suites ±0    98 💤 ±0 
    1 files   ±0   322 ❌ ±0   18 🔥 ±0 

For more details on these failures and errors, see this check.

Results for commit 25a93e3. ± Comparison against base commit e94ebb3.

@canonicalname canonicalname left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved as discussed

@fgogolli
fgogolli merged commit 5070497 into main Jan 21, 2026
46 of 47 checks passed
@fgogolli
fgogolli deleted the fix/package-import-paths branch January 21, 2026 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants