-
Notifications
You must be signed in to change notification settings - Fork 6
Error 413 #52
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
Comments
That's an interesting one @marcelinhov2 , I haven't run into anything like it. There definitely isn't an architectural issue with sending a 5mb (or much larger) - the Lambda functions don't see any of the files, just a hash. What loggroup/function is that error from? None of the functions should be getting any particularly large requests. I just ran a quick test from scratch to make sure nothing new was amiss: npm ci
npx sls deploy -s troytest -r us-west-2 --verbose
aws cognito-idp admin-create-user --user-pool-id us-west-2_jIYHdGO5j --username tready --user-attributes Name=email,Value=troy@example.com Name=phone_number,Value="+12135551212" --message-action SUPPRESS --region us-west-2
aws cognito-idp admin-set-user-password --user-pool-id us-west-2_jIYHdGO5j --username tready --password Testpass@111 --permanent --region us-west-2
aws codecommit create-repository --repository-name testgitlfs --region us-west-2
# repo & LFS in place, now testing them
cd $(mktemp -d)
CC_REPO_URL=https://git-codecommit.us-west-2.amazonaws.com/v1/repos/testgitlfs
git init
git config credential."$CC_REPO_URL".helper '!aws codecommit credential-helper $@'
git config credential."$CC_REPO_URL".UseHttpPath true
git remote add origin $CC_REPO_URL
truncate -s 20M test.dat
git lfs track "*.dat"
git config -f .lfsconfig remote.origin.lfsurl https://eubor6lku0.execute-api.us-west-2.amazonaws.com/troytest
git add .gitattributes .lfsconfig test.dat
git commit -m "initial commit"
git push -u origin main The push output looks like:
The LFS elements of the git config should look something like this:
If nothing stands out as being particularly different, increasing git verbosity (e.g. |
Thanks @troyready , I'll try. The log group I'm showing you is from a lambda that is triggered when a file is dropped in a specific S3 bucket. So my lambda get this file content and try to push to code commit. The message is from here. |
Ah, I see. The primary issue here is that CodeCommit (or whatever other repo you'd be using) doesn't store the actual content of the large files, but instead replaces them with a text pointer as the file in the repo. When a git-lfs enabled git client then receives the file (e.g. during a clone), it reaches out to the git-lfs server (what this project provides) and swaps the file in the working tree with the real large one. So for your design, a couple of thoughts:
import { createHash } from 'node:crypto'
const fileContent = `version https://git-lfs.github.com/spec/v1
oid sha256:${createHash('sha256').update(s3Object.Body).digest('hex')}
size ${record.s3.object.size}
` |
My original comment above was sent early on accident; updated now. |
|
Hey @troyready , thanks for all the help. Apparently it worked. I didn't understood this part Maybe I'm still missing something here. |
I mean that the repo file contents should look like this instead:
(no extra spaces before oid & size) |
I'm having some problem, I didn't identified. but I'm moving forward lol. Now everything seems to be working, except when I try to pull the big files (stored in S3) with the git lfs fetch or git pull command, but It don't download the files. something is wrong from my side yet :( |
For the client to substitute the files properly (replacing the text pointer files stored in the repo with the actual large file in the working tree) you need:
|
Yeah, I didn't made the .git/config piece. going to work on that and try to make it work. Also a good point, I'm using AWS_IAM as the authorizer instead of Cognito. As my lambda has all the roles set, API Gateway enables the request and do the commit. all the main flow is working, now it's a matter of make this link between the pointer and the file correct. Thank you very much for all your help here. |
My pleasure! |
Hey, first of all thanks for the solution. :)
I'm trying to do an implementation using that, I prepared everything and also removed all the auth piece (in order to test the failure I'm getting)
The point is that when I try to push a 5mb file to code commit, after implement everything you shared, I'm getting a 413 error.

After some research, I see the problem is related to pushing big files. Do you already faced it?
Maybe you can point me to the right direction here.
Thanks for the help 🙏 .
The text was updated successfully, but these errors were encountered: