Sudden space export error: "date-fns doesn't accept strings as date arguments"
See original GitHub issueHi, I’m suddenly getting errors when running the contentful export space
. It happened after updating the NPM package to the latest version contentful-cli@1.14.2
.
I experienced it first suddenly in a pipeline (which also used the latest version). In my search for replicating it locally, I updated my local version to the latest one. But now, even when downgrading, the issue strangely remains.
Expected Behavior
Usual export to file, without errors.
Actual Behavior
Error in the CLI output (and also a exported file…)
The following 8 errors and 8 warnings occurred:
Starting with v2.0.0-beta.1 date-fns doesn't accept strings as date arguments. Please use `parseISO` to parse strings. See: https://git.io/fjule
Error
at toDate (/Users/x/.nvm/versions/node/v12.0.0/lib/node_modules/contentful-cli/node_modules/date-fns/toDate/index.js:56:20)
at format (/Users/x/.nvm/versions/node/v12.0.0/lib/node_modules/contentful-cli/node_modules/date-fns/format/index.js:389:42)
at /Users/x/.nvm/versions/node/v12.0.0/lib/node_modules/contentful-cli/node_modules/contentful-batch-libs/dist/logging.js:138:55
at Array.map (<anonymous>)
at displayErrorLog (/Users/x/.nvm/versions/node/v12.0.0/lib/node_modules/contentful-cli/node_modules/contentful-batch-libs/dist/logging.js:138:14)
at /Users/x/.nvm/versions/node/v12.0.0/lib/node_modules/contentful-cli/node_modules/contentful-export/dist/index.js:186:46
at async exportSpace (/Users/x/.nvm/versions/node/v12.0.0/lib/node_modules/contentful-cli/lib/cmds/space_cmds/export.js:181:24)
🚨 Error: Invalid time value
Steps to Reproduce
It at least happens on a export with content:
contentful space export --space-id <x> --environment-id <x> --skip-content false --download-assets true --export-dir <x> --management-token <x>
Context
I’m trying to export all content/content models (including assets) of an existing space, and want to import it in a new empty space.
Environment
Node Version: 12.0.0 Npm Version: 6.9.0 Operating System: Darwin MacBook-Pro.local 20.6.0 Darwin Kernel Version 20.6.0: Mon Aug 30 06:12:21 PDT 2021; root:xnu-7195.141.6~3/RELEASE_X86_64 x86_64 Package Version: contentful-cli@1.14.2 (although after this installation even downgrading to 1.13.0 presents the error, perhaps some cache of a subpackage?)
Pipeline runs on Ubuntu (latest)
Update
It seems to be related to the change of moment to date-fns. Not sure if it’s specifically this release or a few earlier where moment was replaced with date-fns.
One of the changes: https://github.com/contentful/contentful-cli/commit/f3de91ed2b20d126be515ec871740b6502158780?diff=split
As it’s a sub-package, I’ve not yet been able to modify the package correctly…
Issue Analytics
- State:
- Created a year ago
- Comments:5 (1 by maintainers)
Top GitHub Comments
I can confirm that the date-fns fix above, released in contentful-batch-libs 9.4.1, resolved the issue for us. Thanks @Brad-Turner!
Hey @bacpac, this issue was related to replacing moment with date-fns in the contentful-batch-libs repository. I have implemented a fix - just awaiting approval from the team at contentful. 😄