Page MenuHomePhabricator

TemplateConfiguration's parse method should skip misformatted fields or steps individually
Closed, ResolvedPublic

Description

Upon fetching a configuration revision from Meta, the TemplateConfiguration object's parse method is run, which uses the isTemplateDefinition function to determine whether a template definition is valid.

However, a single unsupported fieldname or selection/transformation step configuration value, would make the entire template invalid and ignored.

These errors may be frequent if manually editing configuration files, since our JSON-schemas do not validate string values.

Delegating these checks to the corresponding constructors, as suggested in T302425, would enable individually ignoring the misformatted selection/transformation steps or template fields, instead of ignoring the whole template that they belong to.

Event Timeline

However, a single unsupported fieldname or selection/transformation step configuration value, would make the entire template invalid and ignored.

Given the current state of affairs, in some cases this may result in an uncaught error:

The checks performed by the isTemplateDefinition function (and the more-specific function it calls) are not as strict as the checks performed by the corresponding class constructors.

For example, the isTransformationDefinition function checks that the transformation definition includes a config property, and that it is a string. However, it doesn't check if the config value is valid for the specific transformation type.

Because of this, the isTransformationDefinition function (and the isTemplateDefinition one above) may return true, but the Transformation class constructor will throw an error later on if given an invalid config value.

diegodlh claimed this task.

Fixed in 6eba249

The parse method now is run from the loadRevision method instead of from the fetchRevision method.

As a result, both fetchRevision and getRevision methods return a ContentRevision object (instead of a ConfigurationRevision one), and the DomainConfiguration's revision cache hence stores (unparsed) revision contents.

The parse method of TemplateConfiguration has been updated to validate definitions using the actual constructors, with a new strict option set to false, to skip individual invalid elements (i.e., fields, procedures and steps), instead of dropping the container altogether.

On the other hand, the parse method of PatternConfiguration continues to use the isPatternDefinition function.