Skip to content

fix(OPENFRAM-002-3): NodeDataFetcher uses @Autowired field injection for TenantRepository instead of constructor injection - #1881

Draft
flamingo[bot] wants to merge 1 commit into
mainfrom
ai-fix/openfram-002-3-f0b14697-59051284
Draft

fix(OPENFRAM-002-3): NodeDataFetcher uses @Autowired field injection for TenantRepository instead of constructor injection#1881
flamingo[bot] wants to merge 1 commit into
mainfrom
ai-fix/openfram-002-3-f0b14697-59051284

Conversation

@flamingo

@flamingo flamingo Bot commented Aug 24, 2026

Copy link
Copy Markdown

Closes findings from rule OPENFRAM-002-3 — NodeDataFetcher uses @Autowired field injection for TenantRepository instead of constructor injection.

Draft — this is a starting point, not a finished change. The fix required judgment, so read it before trusting it.

# Fix confidence Finding Location
1 🟡 75 medium NodeDataFetcher uses @Autowired field injection for TenantRepository instead of constructor injection openframe-api-service-core/src/main/java/com/openframe/api/datafetcher/NodeDataFetcher.java:42

What changed — and what was deliberately left — is explained per finding as inline review comments on the lines each finding touched.


Run: https://product-hub.flamingo.so/admin/code-review
Run id: 59051284-b3d6-4391-892c-38c8737386e1

Merging this PR is recorded as acceptance of the rule that produced it;
closing it unmerged is recorded as rejection. Both feed rule health, so
closing a wrong suggestion is useful rather than merely tidy.

…for TenantRepository instead of constructor injection
@flamingo

flamingo Bot commented Aug 24, 2026

Copy link
Copy Markdown
Author

🦩 What this fix changed, finding by finding

1 finding(s) fixed in this draft. (Inline placement was rejected by GitHub for this PR.)

🔴 1. NodeDataFetcher uses @Autowired field injection for TenantRepository instead of constructor injectionopenframe-api-service-core/src/main/java/com/openframe/api/datafetcher/NodeDataFetcher.java:42
Replaced @Autowired(required = false) private TenantRepository tenantRepository; field injection with private final Optional<TenantRepository> tenantRepository;, now populated via the Lombok-generated @RequiredArgsConstructor constructor like the other dependencies. Removed the now-unused org.springframework.beans.factory.annotation.Autowired import and added java.util.Optional. Updated resolveNode in the TENANT case to use tenantRepository.flatMap(repo -> repo.findById(globalId.getId())).orElse(null) instead of the manual null check. This assumes Spring can autowire Optional<TenantRepository> (standard Spring behavior when the bean may be absent) — worth verifying in the actual Spring context/tests that TenantRepository is a conditionally-registered bean rather than always present, since if it's always present this changes nothing functionally but if it's genuinely optional this preserves that semantics correctly.

🤖 Prompt for AI agents
In openframe-api-service-core/src/main/java/com/openframe/api/datafetcher/NodeDataFetcher.java around line 42, review and complete this code-review fix: NodeDataFetcher uses @Autowired field injection for TenantRepository instead of constructor injection.
What the draft fix changed: Replaced `@Autowired(required = false) private TenantRepository tenantRepository;` field injection with `private final Optional<TenantRepository> tenantRepository;`, now populated via the Lombok-generated `@RequiredArgsConstructor` constructor like the other dependencies. Removed the now-unused `org.springframework.beans.factory.annotation.Autowired` import and added `java.util.Optional`. Updated `resolveNode` in the `TENANT` case to use `tenantRepository.flatMap(repo -> repo.findById(globalId.getId())).orElse(null)` instead of the manual null check. This assumes Spring can autowire `Optional<TenantRepository>` (standard Spring behavior when the bean may be absent) — worth verifying in the actual Spring context/tests that TenantRepository is a conditionally-registered bean rather than always present, since if it's always present this changes nothing functionally but if it's genuinely optional this preserves that semantics correctly.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟡 75 medium — react 👍/👎 to teach the reviewer

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.

0 participants