Problem/Motivation
Running drush potx against a site with real contrib modules installed aborts before writing any output. Three separate parser defects each kill the run; core-only sites never hit them, which is why CI stays green.
- A schema
mappingholding scalars is fatal._potx_process_config_schema()(potx.inc:2611) declaresarray $schema_dataand hands eachmappingvalue to itself. A malformed element passes a string. Shipped by diff:
diff.layout_plugins: type: config_object mapping: type: sequence sequence: ...TypeError: _potx_process_config_schema(): Argument #2 ($schema_data) must be of type array, string given - Scalar
dependenciesin an .info.yml is fatal. potx.inc:2482 iterates the key and laterarray_merge()s it.dependencies: 'drupal:user'instead of a list givesforeach() argument must be of type array|object, string given, thenarray_merge(): Argument #2 must be of type array, string given. Shipped by force_password_change and htmlpurifier. - Config exports are misread as module info files. potx.inc:2468 matches
~[^/]+\.info\.yml~, so a base field override for a field named "info" —core.base_field_override.block_content.basic.info.ymlin a config sync directory — is treated as a module's info file. Itsdependenciesis a config mapping, givingArray to string conversion.
Each is independently fatal, so fixing one only exposes the next.
Steps to reproduce
- Install diff, force_password_change or htmlpurifier, or export config containing a base fielcode>info.
- Run
drush potxfrom the Drupal root. - The command terminates abnormally and writes no .pot file.
Also reproducible as a test failure: PotxCommandsTest::testCommands runs bare
Proposed resolution
Malformed third-party YAML should be skipped, not abort extraction.
- Accept
mixed $schema_datain_potx_process_config_schema()and retrray. - Cast
dependenciesandinstallto array when reading an .info.yml.< - Require
typeto be module, theme or profile before treating a*.info.yml
Remaining tasks
- Review the fix and its kernel test coverage.
User interface changes
None.
Obligatory mention of use of LLM
Issue fork potx-3620739
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 3620739-3.x
changes, plain diff MR !72
- 3620739-drush-potx-aborts
changes, plain diff MR !59
Comments
Comment #3
heddnTest failures are pre-existing. Fixed over in https://git.drupalcode.org/project/potx/-/merge_requests/58/diffs?file_p.... Let me know if you want that extracted into a dedicated PR.
Comment #4
gábor hojtsyThanks for the report!
Of the problems the first one is fixed by #3630545: Config and YAML strings potx misses: invalid schema elements, schema of config dependencies, patterns without keys: potx reports an error for a schema element with a single value, like
type: sequencein diff, and extracts the rest of the schema. I think the solution there was better because it reports an error instead of silently skipping it.The other two crash 3.x too, with a TypeError at the end of the run.
Looking at localize.drupal.org data about prior parsing runs, these sample releases are actually affected too:
*.info.ymlinconfig/defaultorconfig/sync. Config files inconfig/installandconfig/optionalare not affected, because potx reads them as shipped config first and do not go on to parse them as info files. On localize.drupal.org, the crash means that the releases have no strings at all.I decided to solve the problems a bit differently for 3.x.
.info.ymlfile of an extension only when its name is the machine name of an extension, likeExtensionDiscoverydoes in core. Config names always have a dot, likecore.base_field_override.block_content.basic.info.yml, so this does not depend on thetypekey. There was a slim chance that the type key could have false positives still, and using a file name pattern means we don't actually need to even parse the file.Both have unit tests, and a kernel test runs a whole extraction with both files. The output of a sample of 51 core and contrib projects is the same with and without the change.
LLM disclosure
LLM was used to further diagnose, explain and fix this issue. With human review.
Comment #5
gábor hojtsyComment #8
gábor hojtsy