I ran into something that feels a bit unintuitive (and possibly a bug) when referencing module settings for a private ForgeBox module.
The exception
When a private module is installed as a dependency and the module code tries to inject its own settings like this:
property name="settings" inject="coldbox:moduleSettings:my-private-module";
ColdBox throws the following exception at runtime:
The DSL provided was not valid:
{
ref={null},
delegateExcludes={[]},
delegatePrefix={},
delegateSuffix={},
required={true},
argName={},
delegateIncludes={[]},
javaCast={null},
dsl={coldbox:moduleSettings:my-private-module},
name={settings},
type={any},
delegate={false},
scope={variables},
value={null}
}
What Iāve observed
If the module is private on ForgeBox, accessing its settings appears to require the ForgeBox username to be appended to the module name.
For example, instead of:
getModuleSettings( "my-private-module" );
you must do:
getModuleSettings( "my-private-module@forgeboxUser" );
This works fine from the parent application that installs the module as a dependency.
However, it becomes problematic when building the module itself.
Why this feels odd
Inside the moduleās own codebase:
- The moduleās test harness works with:
property name="settings" inject="coldbox:moduleSettings:my-private-module";
- But once the module is installed as a dependency, the same code fails, unless the module name includes the ForgeBox username.
That means the module itself must āknowā the ForgeBox username it was published under, which feels like a leaky abstraction. From a module authorās perspective, Iād expect the module to be able to reference its own settings by its canonical module name, regardless of whether itās public or private.
Is this expected behavior for private ForgeBox modules, or is this a known limitation/bug in how moduleSettings are resolved?
If expected, is there a recommended pattern for modules to safely reference their own settings without hard-coding the ForgeBox username?