Skip to content

Conversation

@samuelmbabhazi
Copy link
Contributor

@samuelmbabhazi samuelmbabhazi commented Dec 3, 2025

PR

Please note: we will close your PR without comment if you do not check the boxes above and provide ALL requested information.



Summary by cubic

Fix invalid MikroORM repository injection that caused empty repositories and startup errors. Removes duplicate repository providers and uses a forked EntityManager during bootstrap for reliable counts.

  • Bug Fixes
    • Removed MikroOrm*Repository from providers/exports across core and plugins, relying on MikroOrmModule.forFeature to register repositories correctly.
    • Exported MikroOrmModule where needed to keep downstream access to properly injected repositories.
    • In UserService.countFast(), forked MikroORM’s EntityManager during bootstrap to avoid global EM context errors.

Written for commit 1fe16de. Summary will update on new commits.

…elated modules

Remove MikroOrm*Repository from providers/exports arrays in:
- user.module.ts
- role.module.ts
- user-organization.module.ts
- employee.module.ts

These repositories are already properly created by MikroOrmModule.forFeature().
Registering them again as simple providers overwrites the correct instances
with empty ones (undefined EntityManager).

Fixes #8700
…zation-team modules

Remove MikroOrm*Repository from providers/exports arrays in:
- organization-team.module.ts
- organization-team-employee.module.ts

Part of MikroORM repository injection fix.

Fixes #8700
…racking modules

Remove MikroOrm*Repository from providers/exports arrays in:
- time-log.module.ts
- custom-tracking.module.ts

Part of MikroORM repository injection fix.

Fixes #8700
…odules

Remove MikroOrm*Repository from providers/exports arrays in:
- expense-categories.module.ts
- employee-availability.module.ts

Part of MikroORM repository injection fix.

Fixes #8700
…shot/soundshot

Remove MikroOrm*Repository from providers arrays in:
- camshot.module.ts
- soundshot.module.ts

Part of MikroORM repository injection fix.

Fixes #8700
…egration modules

Remove MikroOrm*Repository from providers arrays in:
- zapier.module.ts
- github.module.ts

Part of MikroORM repository injection fix.

Fixes #8700
…-proposal

Remove MikroOrm*Repository from providers arrays in:
- employee-proposal-template.module.ts
- proposal.module.ts

Part of MikroORM repository injection fix.

Fixes #8700
…kroORM

During application bootstrap, there is no HTTP request context, so MikroORM's
global EntityManager cannot be used directly (ValidationError: Using global
EntityManager instance methods for context specific actions is disallowed).

Solution: Fork the EntityManager in countFast() when using MikroORM to ensure
proper context during bootstrap operations.

Fixes #8700
@samuelmbabhazi samuelmbabhazi self-assigned this Dec 3, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 3, 2025

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/mikro-orm-repository-injection-8700

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@rahul-rocket
Copy link
Collaborator

@samuelmbabhazi We still have the MikroORM issue, right? Do you want me to work on fixing it?

@samuelmbabhazi
Copy link
Contributor Author

@samuelmbabhazi We still have the MikroORM issue, right? Do you want me to work on fixing it?

Yes please @rahul-rocket !

@sonarqubecloud
Copy link

@rahul-rocket rahul-rocket deleted the fix/mikro-orm-repository-injection-8700 branch January 28, 2026 05:09
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.

[Fix] Global EntityManager Context Issue in Mikro ORM Configuration

2 participants