Skip to content
This repository was archived by the owner on Mar 18, 2024. It is now read-only.
This repository was archived by the owner on Mar 18, 2024. It is now read-only.

sfdx-project.json validation incorrectly rejecting unpackagedMetadata #958

Closed

Description

@yippie

Describe the bug
sfpowerscripts:orchestrator:prepare reports that my sfdx-project.json file is invalid when using the
unpackagedMetadata flag documented here: https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_unlocked_pkg_unpackaged_md.htm

To Reproduce
specify unpackage metadata for your package as documented here https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_unlocked_pkg_unpackaged_md.htm

Attempt to build the pool with sfpowerscripts:orchestrator:prepare

Expected behavior
Scratch orgs to build

Screenshots
If applicable, add screenshots to help explain your problem.

Platform Details (please complete the following information):

  • OS: macOS 12.3.1
  • Version: @dxatscale/sfpowerscripts 13.0.14
    sfdmu 4.13.0
    sfpowerkit 4.2.5
  • Salesforce CLI(sfdx cli) Version:sfdx-cli/7.143.0 darwin-arm64 node-v16.14.2

Additional context
Add any other context about the problem here.

Activity

  1. added
    analysis
    on Apr 29, 2022
  2. azlam-abdulsalam commented on Apr 29, 2022

    @azlam-abdulsalam
    Contributor

    @yippie We currently do not support 'unpackagedMetadata'. We are looking into how better to address this from an artifact perspective.

    Supported schema is

    https://github.com/Accenture/sfpowerscripts/blob/main/packages/sfpowerscripts-cli/resources/schemas/sfdx-project.schema.json

    Refer to #921

  3. yippie commented on May 20, 2022

    @yippie
    Author

    Unpackaged is exactly that "unpackaged" it is only needed and used for the unit tests in an sfdx package:version:create call.

    As far as sfpowerscripts is concerned, I would expect it to be completely ignored as it is ONLY needed by Salesforce for salesforces own package validation of unit tests.

    Currently it is blocking, if I have it, it rejects my project file and aborts. I want the unpackaged to be ignored so I can use sfpowerscripts but still package my unlocked packages correctly.

  4. vuha-acn commented on May 20, 2022

    @vuha-acn
    Contributor

    @yippie - Is there a particular business reason why the "unpackaged" test classes would not want to be included in the package creation. In the Salesforce Docs, they do not really specify the business case to not include this but provide it as an option. Just wanted to see the context of this use case and why it would not just be included in the package folder for completeness.

  5. yippie commented on May 20, 2022

    @yippie
    Author

    @vuha-acn it is not unpackaged test classes. it is unpackaged Custom Metadata Records for a managed package we depend on. The managed package has triggers on objects we do test against (like task) that throw null pointers if the CMT does not exist (ie, in the packaging org). The "fix" is to include unpackaged CMT during package creation. If we don't include the metadata, our unit tests fail because the managed package code is throwing null pointers expecting a CMT record when there aren't any.

  6. yippie commented on May 20, 2022

    @yippie
    Author

    in #921, all three of the things you removed are ONLY used by sfdx force:package:version:create and the only thing sfpowerscripts needs to do to completely support them is to allow the sfdx force:package:version:create command to see them. There is nothing else to do with them so blocking their usage is just removing packaging options from people needlessly.

    They are just used by salesforce servers to affect how the package behaves on salesforce servers. They should have no affect on sfpowerscripts or dx@scale flow.

    Please put them back in the schema (or better yet, don't do a blocking schema check at all, if sfpowerscripts can add custom options, why can't I for my own use?)

  7. yippie commented on May 23, 2022

    @yippie
    Author

    There more I look at this the less sense it makes. sfpowerscripts currently is taking full ownership of sfdx-project and locking everyone else out. To use SFPowerscripts at all I have to ONLY use sfpowerscripts and cannot put my own notes or usage in it or even use all STANDARD salesforce features.

    I would like to propose the following change to the sfdx-project.schema.json file to fix this:
    Screen Shot 2022-05-23 at 12 36 47 PM

    Please please please consider doing this change and being better citizens

  8. azlam-abdulsalam commented on May 23, 2022

    @azlam-abdulsalam
    Contributor

    Yes, we could unblock unpackaged, but unpackaged being generic can point to any other source package or any other path.

    During a parallel build sfpowerscripts create individual working directory for each package and we need to ensure the unpackaged directory is correctly copied into the working directory. This is currently not supported and once it is added we can add that back. There is a similar issue raised as #842

    On the additional properties path, we are just being strict, for eg, if you add an additional property to unlocked package, it will fail during version:create. All additional sfpowerscripts properties are cleansed before being send to salesforce. .But we could have an optional environment variable to remove the check.

    Please feel free to raise a PR or we could schedule for a future release

  9. azlam-abdulsalam commented on May 23, 2022

    @azlam-abdulsalam
    Contributor

    Also, do you see how this plays out during validate command? Ignore this unpackaged directory?

  10. yippie commented on May 24, 2022

    @yippie
    Author

    I would expect it to be completely ignored for all commands and tasks except for calling force:package:version:create. It is often pointing at another "real" package directly as typically you also will want/have the unpackaged in your scratch org for development also. The unpackaged directory is never, and should never, be sent or deployed to any orgs. It is nothing more than required config for unit tests to pass in a "packaging org" basically as a work around for the fact that scratch-def doesn't cover everything.

  11. azlam-abdulsalam commented on May 25, 2022

    @azlam-abdulsalam
    Contributor

    Yep, the pointing to the 'real' package is where it gets tricky. That means this is a something that need to be part of development scratch org, so it implies it has to be part of prepare as well, where prepare only uses last known validated package to build the scratch org

    My current proposal is the following

    • Any such unpackaged addition shouldn't point to a real package. Lets reject if we find any
    • We will pack the unpackaged metadata into the artifact and will be deployed 'after' the actual contents of the package is deployed.
  12. yippie commented on May 26, 2022

    @yippie
    Author

    Are you trying to fake a packaging org (IE set up a scratch org identically to salesforce package validation orgs)? If you are, sure, but the unpackaged tag should never, ever be deployed to a pool scratch org, development scratch org, sandbox or production...ever.

    If something should be deployed, I will, and people should, be making actual packages for them and then you just deploy the regular package list.

    Unpackaged means exactly that, unpackaged, it is something that should not be packaged or distributed (although its contents might be shared with a real package). It is in practice and intent, an extension on the scratch-def.json used by salesforce for creating a new package version ID via force:package:version:create.

    Please don't ever deploy it or restrict it, just make it available to the force:package:version:create command so that salesforce packaging can succeed. When developing and deploying from artifacts it should not exist.

    Best practice is likely the opposite of what you proposed. Likely unpackaged SHOULD be pointing at a real package. That way you are developing with the same config that salesforce packages with. We had it different because we only needed a stripped down subset (3 custom metadata type records) to get unit tests to pass when packaging, but if I had to make it a real package with sfpowerscripts I wouldn't blink.

  13. yippie commented on May 26, 2022

    @yippie
    Author

    I guess ultimately what I am asking is that the native force:xxx behavior is maintained and not changed or restricted. force:push/pull never touch or look at the unpackagedMetadata directory. ONLY force:package:create does. As far as any other command is concerned, it doesn't exist and it never sees the light of day after the package is made.

  14. added
    enhancement
    and removed
    analysis
    on Jun 3, 2022
  15. added a commit that references this issue on Jun 16, 2022
    c2569bf
  16. added a commit that references this issue on Jun 16, 2022
    6c04f6d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

enhancement

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions