Skip to content

Fix recomposition failing for child components #112

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 13, 2020
Merged

Conversation

brpowell
Copy link
Contributor

@brpowell brpowell commented Aug 13, 2020

What does this PR do?

Fixes source conversion for child components of a decomposed type. The issue was during the manifest generation step where the type "did not exist" for the child component. The registry access getTypeFromName only supports getting top level types at the moment so this doesn't work as expected.

This issue came up after a failed rebase/merge in the last PR 🤦‍♂️

What issues does this PR fix or reference?

@W-7672773@

Functionality Before

 UnhandledPromiseRejectionWarning: TypeInferenceError: Missing metadata type definition in registry for id 'customfield'
    at RegistryAccess.getTypeFromName (/Users/b.powell/dev/source-deploy-retrieve/lib/src/metadata-registry/registryAccess.js:46:19)
    at ManifestGenerator.createMetadataMap (/Users/b.powell/dev/source-deploy-retrieve/lib/src/metadata-registry/manifestGenerator.js:45:54)
    at ManifestGenerator.createManifest (/Users/b.powell/dev/source-deploy-retrieve/lib/src/metadata-registry/manifestGenerator.js:30:34)
    at MetadataConverter.<anonymous> (/Users/b.powell/dev/source-deploy-retrieve/lib/src/convert/metadataConverter.js:35:60)
    at Generator.next (<anonymous>)
    at /Users/b.powell/dev/source-deploy-retrieve/lib/src/convert/metadataConverter.js:8:71
    at new Promise (<anonymous>)
    at __awaiter (/Users/b.powell/dev/source-deploy-retrieve/lib/src/convert/metadataConverter.js:4:12)
    at MetadataConverter.convert (/Users/b.powell/dev/source-deploy-retrieve/lib/src/convert/metadataConverter.js:31:16)
    at test (repl:8:26)
(node:11032) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:11032) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Functionality After

Working as expected

@brpowell brpowell requested a review from a team as a code owner August 13, 2020 17:51
metadataMap.set(metadataType, metadataNames);
const {
fullName,
type: { name: typeName },
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of asking the RegistryAccess for the type, this just pulls it right off the component since we have that information already. getTypeFromName currently only supports top level metadata types. If we feel like it's necessary to strictly enforce a metadata type defined in the registry.json file to use the manifest generator, this could be done instead:

const { name: typeName } = component.parent
        ? this.registryAccess.getTypeFromName(component.parent.type.name).children.types[
            component.type.id
          ]
        : this.registryAccess.getTypeFromName(component.type.name);

Most of the time however, components are constructed from the registry code and even the type property itself is strictly typed.

@brpowell brpowell requested a review from jag-j August 13, 2020 18:00
metadataMap.set(metadataType, metadataNames);
const {
fullName,
type: { name: typeName },
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prettier fix - "," at the end

@brpowell brpowell merged commit fd4a3ab into develop Aug 13, 2020
@brpowell brpowell deleted the bp/recompositionFix branch August 13, 2020 18:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants