fix(simulator): reject a performance storage URI that is not an absolute URL (#2169)
* fix(simulator): reject a performance storage URI that is not an absolute URL
performanceStorage.uri (and its deprecated URI alias) accepted any
string, but the simulator parses it with new URL() while building the
configuration at module load and in the Storage constructor. A value
such as "not a url" or a relative path like "performance/records.json"
therefore crashed the simulator with a bare "TypeError: Invalid URL"
that did not name the field.
Validate the value with URL.canParse() in the configuration schema so
it is reported as a configuration error on performanceStorage.uri (or
performanceStorage.URI) instead. The narrowing is folded into the
unreleased configuration schema version 2.
Signed-off-by: VitorCoelho <vitorc195@gmail.com>
* fix(simulator): validate performanceStorage.uri only where the simulator parses it
The simulator parses the URI at load time for the jsonfile and sqlite
storage types and when it opens an enabled storage. Values the simulator
never reads, including the deprecated URI alias, are left unvalidated so
existing configurations keep loading.
Signed-off-by: VitorCoelho <vitorc195@gmail.com>
* test(utils): cover performanceStorage.uri only where the simulator parses it
Signed-off-by: VitorCoelho <vitorc195@gmail.com>
* fix(simulator): validate performanceStorage.uri for remote backends with enabled omitted
The mongodb, mysql and mariadb backends inherit 'enabled: true' from the
default storage configuration, so the storage is opened and the URI parsed
unless 'enabled' is false. Treat an omitted 'enabled' as enabled for them.
mongodb, mysql and mariadb sections without 'enabled' now reject a
relative uri; sections with 'enabled: false' and a bare '{ enabled: true }'
section are still accepted.
Signed-off-by: VitorCoelho <vitorc195@gmail.com>
* refactor(simulator): share the performance storage enabled default with the schema
The schema resolved an omitted 'performanceStorage.enabled' with
'enabled !== false', which re-encodes the 'enabled: true' default of
defaultStorageConfiguration in Configuration.ts. Move that boolean to
Constants.DEFAULT_PERFORMANCE_STORAGE_ENABLED, use it in the runtime default
and resolve the schema fallback with 'value.enabled ?? default', so a change
to the canonical default is followed by validation. No behaviour change.