lambci / docker-lambda

Docker images and test runners that replicate the live AWS Lambda environment
MIT License
5.83k stars 431 forks source link

C# Runtime - logs variable not set #282

Closed AdamLewisGMSL closed 4 years ago

AdamLewisGMSL commented 4 years ago

I've been writing LambdaClient code recently so we can get one lambda in docker to call another. It's mostly happy but there's an issue with the logs variable in MockRuntime.cs not being initialised. In more detail:

Have circumvented the issue by compiling a null check and loading in a custom version to the docker image but it's not a long term fix

mhart commented 4 years ago

Can look at this, but out of interest, is there a reason you're using the old .NET 2.1 runtime and not the newer 3.1 one?

AdamLewisGMSL commented 4 years ago

We're in the process of upgrading our code from 2.1 to 3.1 at the moment (which is currently failing due to deserialization issues) so I may be back with move problems if I can't figure that out ;)

mhart commented 4 years ago

Also, do you want to submit a PR for the changes you've made?

AdamLewisGMSL commented 4 years ago

Afraid I don't have time to check if the same change needs to happen in the other runtimes at the moment but I don't mind sharing the hacked into 2.1 fix: `private byte[] LogsTail4k() { if(logs != null) { var logBuf = Encoding.UTF8.GetBytes(logs); if (logBuf.Length <= 4096) { return logBuf; } var slicedLogBuf = new byte[4096]; Array.Copy(logBuf, logBuf.Length - 4096, slicedLogBuf, 0, 4096); return slicedLogBuf; }

        return new byte[4096];
    }`
AdamLewisGMSL commented 4 years ago

Tried to create a branch for a PR - authorisation issues?

mhart commented 4 years ago

Not sure what you mean?

AdamLewisGMSL commented 4 years ago

git push --set-upstream origin DOTNETNullCheck_#282 remote: Permission to lambci/docker-lambda.git denied to AdamLewisGMSL. fatal: unable to access 'https://github.com/lambci/docker-lambda.git/': The requested URL returned error: 403

mhart commented 4 years ago

You can't push to this repository – that's true of any repository on GitHub that you're not a member of.

Have a look at https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request-from-a-fork for how to make PRs

AdamLewisGMSL commented 4 years ago

Got it - PR should be open

mhart commented 4 years ago

And https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/working-with-forks for more info on forks

mhart commented 4 years ago

Fixed in https://github.com/lambci/docker-lambda/commit/5ca3009aebfe1fe05e5c5aebec4a96b4648beb08