add missing unpackaged metadata option#3991
Conversation
jstvz
left a comment
There was a problem hiding this comment.
Adds an unpackaged_metadata_path option to create_package_version so the build org used during package version creation can deploy extra metadata that Apex tests in the package depend on. The option writes unpackaged-metadata.zip into VersionInfo and sets package_descriptor["unpackagedMetadata"], matching the SFDX unpackagedMetadata semantics. Tests assert presence in the positive case and absence in the negative case.
Two correctness issues to address before merge (inline):
-
The new block runs every time
_create_version_requestis called, including the two dependency calls at lines 684 and 719. The configured path will be attached to every unlocked dependency package, not only the main package. The existing dependencies block at line 432 gates onis_dependency; mirroring that gate looks correct. -
A missing
unpackaged_metadata_pathdirectory currently surfaces as a rawFileNotFoundErrorfromconvert_sfdx_source. Validating in_init_optionswould give a clearer error.
Two minor cleanups (non-blocking): the new version_info.writestr call sits outside the with convert_sfdx_source(...) block (the analogous settings block keeps it inside; works because the zip builder buffers in BytesIO, but the asymmetry reads like a scope bug), and the new tests re-import BasePackageZipBuilder locally even though it is imported at module scope.
The descriptor key, the zip entry, and the test coverage all line up with the SFDX behavior the linked issue (#3989) calls out.
jstvz
left a comment
There was a problem hiding this comment.
Lint is clean locally (ruff check passes). The "Lint / Lint" CI failure on this SHA is a workflow infrastructure issue (fatal: couldn't find remote ref feature/add-unpackaged-metadata-support) unrelated to code quality.
The remaining failing checks (3.14 unit tests, Robot, Test SFDX CLI, Org-connected) reproduce on every PR right now and trace to the SF CLI 2.136 [REDACTED] token issue (#3987) plus the Python 3.14 matrix cap. Out of scope here.
LGTM.
Add support for the Salesforce "unpackaged Metadata" option when creating package versions.
https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_dev2gp_unpackaged_md.htm
Fixes #3989