Skip to content

docs(web/guides): dependency-injection-usage states two wrong container mechanics — singleton cache keying and case-sensitive binding names #3117

Description

@bpamiri

Summary

Two factual errors on web/sites/guides/src/content/docs/v4-0-0/digging-deeper/dependency-injection-usage.mdx, found by the 2026-06 guide behavioral audit (P2 p2-4-digging). Checked against #3061 and #3063 — neither covers these (those are the onError container wipe and the Adobe var-in-services.cfm boot failure).

1. Singleton cache mechanism inverted (line 67)

Guide: "because asSingleton() caches the first instance per component path, you want the fake under a different component path ... so the cache doesn't hand you a stale real instance."

Source (vendor/wheels/Injector.cfc): the singleton cache is keyed by alias (lines 25-29 — the per-component-path keying is explicitly described as the old, fixed behavior), and to() invalidates the alias's cached instance when re-binding to a different path while keeping it on same-path re-registration (lines 97-108). The prescription (different fake path) still works — precisely because the different-path re-bind triggers the invalidation — but the stated mechanism is backwards. Behavioral pin: vendor/wheels/tests/specs/di/InjectorLifecycleSpec.cfc.

Fix: reword to "the singleton cache is keyed by the binding name; re-binding the name to a different component path invalidates the cached instance, so register the fake under its own component path and the container drops the stale real instance."

2. "Binding names are case-sensitive" is false (line 244)

Guide: "Names are case-sensitive. service("EmailService") and service("emailService") are different keys."

Source: mappings/singletons/flags are plain CFML structs (Injector.cfc:23,30,33) resolved via structKeyExists (:168,185,282,319). CFML struct keys are case-insensitive on Lucee/Adobe/BoxLang; probed on Lucee: structKeyExists({"emailService": ...}, "EMAILSERVICE")true and the mixed-case lookup resolves. Both spellings hit the same binding, so this debugging bullet sends users chasing a non-existent failure mode.

Fix: delete the bullet, or replace with real failure modes (typo'd name → unresolved-path error; container wiped after an error page → #3061).

Acceptance

  • Line 67 describes alias-keyed caching + different-path invalidation.
  • Line 244 no longer claims case-sensitivity.

Dedupe: distinct from #3061/#3063 (verified); pure docs — the docs wave (manifest Group 5) may close this directly. Claims dependency-injection-usage-02 and -03 (Lucee probe + Injector.cfc source).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions