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

zip does not support timestamps before 1980 aws #1977

Closed
devTalha opened this issue Mar 17, 2018 · 14 comments · Fixed by #1979
Closed

zip does not support timestamps before 1980 aws #1977

devTalha opened this issue Mar 17, 2018 · 14 comments · Fixed by #1979
Labels
guidance Question that needs advice or information.

Comments

@devTalha
Copy link

We are having projects created with aws codestar. these were working fine. but from today we are facing following issue:
Logs:
'Unable to upload artifact None referenced by CodeUri parameter of GetCompanyRecords resource. zip does not support timestamps before 1980'

Now when i removed aws-sdk module again it works fine. but when i add it again build fails. i am pretty much worried about this. Here is my lambda function.

GetCompanyRecords:
Type: AWS::Serverless::Function
Properties:
Handler: index.handler
Runtime: nodejs6.10
Role:
Fn::ImportValue:
!Join ['-', [!Ref 'ProjectId', !Ref 'AWS::Region', 'LambdaTrustRole']]
Timeout: 10
Events:
PostEvent:
Type: Api
Properties:
Path: /getCompanyRecords
Method: post

Here is pacakge.json
"dependencies": {
"aws-sdk": "^2.211.0",
"aws-serverless-express": "latest",
"body-parser": "^1.18.2",
"chai": "^4.1.2",
"chai-http": "^3.0.0",
"cors": "^2.8.4",
"country-list": "^1.1.0",
"express": "^4.16.2",
"mocha": "^5.0.0",
"promise": "^8.0.1",
"provinces": "^1.11.0",
"underscore": "^1.8.3",
"uuid": "^3.2.1"
}

Thanks in advance

@zimny
Copy link

zimny commented Mar 19, 2018

+1

1 similar comment
@abajowski
Copy link

+1

@gbegher
Copy link

gbegher commented Mar 19, 2018

+1 -- related: feross/ieee754#17

@devTalha
Copy link
Author

I am facing this issue explicitly with 'aws-sdk'. When i add it in node modules i get the exception but when i remove it's all fine.

@devTalha
Copy link
Author

devTalha commented Mar 19, 2018

@zimny , @abajowski , @gbegher at the moment following patch fixed my issue:

I added following lines to buildspec.yml after 'npm install'

  • ls $CODEBUILD_SRC_DIR
  • find $CODEBUILD_SRC_DIR/node_modules -mtime +10950 -exec touch {} ;

But i want aws to fix to this issue. I am really disappointed aws-sdk is not working with aws..

@dkrosso
Copy link

dkrosso commented Mar 19, 2018

+1

@chrisradek
Copy link
Contributor

chrisradek commented Mar 19, 2018

@devTalha
Can you share the code that's resulting in the error you're seeing?

Edit:
Oh I see, do you mean you're having an issue when trying to deploy a package with the aws-sdk included in a zip?

@chrisradek
Copy link
Contributor

As an immediate workaround, adding 'ieee754': '1.1.8' to your dependencies will pull in a version that does not have files with a very old timestamp. It looks like the most recent version of this dependency still has very old timestamps for some of its files. We'll open an issue there to fix the timestamps, and can pin the dependency to 1.1.8 as well.

@TonyFNZ
Copy link

TonyFNZ commented Mar 20, 2018

I have upgraded to v2.211.1 and done a clean install, but I still get this issue when running aws cloudformation deploy ....

Similar to @devTalha, the following command fixes things for me:

find ./node_modules -mtime +10950 -exec touch {} \;

Note, prior to running the above command, the following files appear to have very old modified dates:

$ find ./node_modules -mtime +10950
./node_modules/hosted-git-info/CHANGELOG.md
./node_modules/hosted-git-info/git-host-info.js
./node_modules/hosted-git-info/git-host.js
./node_modules/hosted-git-info/index.js
./node_modules/hosted-git-info/LICENSE
./node_modules/hosted-git-info/README.md
./node_modules/lru-cache/index.js
./node_modules/lru-cache/LICENSE
./node_modules/lru-cache/README.md
./node_modules/regexpp/index.d.ts
./node_modules/regexpp/index.js
./node_modules/regexpp/index.js.map
./node_modules/regexpp/LICENSE
./node_modules/regexpp/README.md

@devTalha
Copy link
Author

@chrisradek mentioned patch fixes the issue. But again i want aws to fix their issue as it spoiled my weekend roundly 48 hours. so anyone else doesn't have issue and aws-sdk works with aws pipeline. And yeah you got it right it happens when i add aws-sdk to my dependencies.

Thanks for concern.

@chrisradek
Copy link
Contributor

@TonyFNZ and others
Zip files don't support files with timestamps prior to 1980. Some tools will get around this by actually changing dates to Jan 1 1980, but this is unexpected (and potentially dangerous) behavior.

The CodeBuild job that you're running is using the CLI (written in python) to generate a zip file. Python's zipfile module explicitly throws an error when it encounters files dated before 1980, rather than attempt to change the dates.

We patched the SDK so we could be sure none of our dependencies contained files dated prior to 1980. Any other library you're using that has the same problem would need to republish as well.

As an aside, it looks like there was an issue with NPM that was causing incorrect file timestamps, so it's likely this is what's leading to packages having incorrect dates:
npm/npm#19968

@JimLynchCodes
Copy link

JimLynchCodes commented May 9, 2018

wow, thanks @devTalha for starting this thread and everyone else for helping to solve it. I too just came in one morning to my projects that were using CodePipeline / CodeBuild and was in a panic because all of my projects were failing on the build stage with the exact same error (same one that op describes in his Logs but with my resource name), even ones whose source code I hadn't touched in months!

Anyway, after adding the command from @TonyFNZ after the npm install command my buildspec.yml my build stages passed again, and it was smooth sailing.

version: 0.2

phases:
  install:
    commands:
      # Install dependencies needed for running tests
      - npm install

      # Prevent files from having a timestamp before 1980
      - find ./node_modules -mtime +10950 -exec touch {} \;

      # Upgrade AWS CLI to the latest version
      - pip install --upgrade awscli
  pre_build:
    commands:
      # Discover and run unit tests in the 'tests' directory
      - npm test
  build:
    commands:
      # Use AWS SAM to package the application using AWS CloudFormation
      - aws cloudformation package --template template.yml --s3-bucket $S3_BUCKET --output-template template-export.yml
artifacts:
  type: zip
  files:
    - template-export.yml

Case closed.

rlmartin added a commit to rlmartin/apibuilder-code-generator that referenced this issue Jun 23, 2018
rlmartin added a commit to rlmartin/apibuilder-code-generator that referenced this issue Jun 23, 2018
Ro5635 added a commit to Ro5635/authenticationService that referenced this issue Sep 5, 2018
 modification date of 1985. Post npm install now touches files to update
 the modification date.

 Workaround sourced from: aws/aws-sdk-js#1977

 On branch dev

 Changes to be committed:
	modified:   buildspec.yml
@arcemunozo
Copy link

The problem is the version project and the version cloudformation nodejs.

@srchase srchase added the guidance Question that needs advice or information. label Dec 7, 2018
@trivikr trivikr mentioned this issue Sep 17, 2019
6 tasks
@lock
Copy link

lock bot commented Sep 29, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

@lock lock bot locked as resolved and limited conversation to collaborators Sep 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
guidance Question that needs advice or information.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants