Skip to content
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

When running env import, add a default "objects" property to the package object #510

Closed

Conversation

jgoachermedable
Copy link
Collaborator

The mdctl env import command fails with the following error when run in the same directory as a package.json file which doesn't have an "object" property:

  object: 'fault',
  name: 'error',
  errCode: 'cortex.invalidArgument.unspecified',
  code: 'kInvalidArgument',
  message: 'Invalid Argument',
  status: 400,
  trace: undefined,
  path: undefined,
  resource: undefined,
  reason: 'The resource is missing the object property.',
  index: 0

The current workaround when this happens is to delete the package file.

This PR provides a fix by ensuring that an object loaded from a package.json file has an object property defaulted to the value package.

@@ -102,8 +102,11 @@ class ImportFileTreeAdapter extends EventEmitter {

async loadPackageFromObject() {
const { packageData, input, format } = privatesAccessor(this),
section = new ImportSection(packageData, 'package', `package.${format}`, input)
return { results: [section.content], blobResults: [] }
{ content } = new ImportSection(packageData, 'package', `package.${format}`, input)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Note that the only effect of the new ImportSection call here is to map packageData to the new object's content property, so lines 104-105 could be replaced with just:

const { packageData: content, input, format } = privatesAccessor(this)

@jgoachermedable
Copy link
Collaborator Author

Closing, as mdctl should only be run within a folder with a package.json with an object property, e.g. see https://gitlab.medable.com/axon/org/-/blob/development/configuration/package.json

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.

1 participant