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

Unexpected error + traceback #128

Open
gamename opened this issue Jan 5, 2017 · 4 comments
Open

Unexpected error + traceback #128

gamename opened this issue Jan 5, 2017 · 4 comments
Assignees

Comments

@gamename
Copy link

gamename commented Jan 5, 2017

Hi,

I just upgraded and am having problems with a lambda.json file that previously worked. Can you tell me what I'm doing wrong?

Here is my version

$ lambda-uploader --version
1.1.0

I'm getting this error:

lambda-uploader --publish ./ngd
⁉️ Unexpected error. Please report this traceback.
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/lambda_uploader/shell.py", line 182, in main
    _execute(args)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/lambda_uploader/shell.py", line 51, in _execute
    variables=args.variables)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/lambda_uploader/config.py", line 40, in __init__
    self._load_config(config_file)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/lambda_uploader/config.py", line 144, in _load_config
    raise Exception("%s not a valid configuration file" % lambda_file)
Exception: lambda.json not a valid configuration file
make: *** [build] Error 1

This is the content of my lambda.json file (with account redacted):

{
  "name": "ngd",
  "description": "Main Function. Calls all other lambdas",
  "region": "us-east-1",
  "handler": "ngd.handler",
  "role": "arn:aws:iam::1234567890:role/audit_role",
  "requirements": [],
  "ignore": [
    "/.*\\.pyc$"
  ],
  "timeout": 30,
  "memory": 512
}
@jarosser06
Copy link
Contributor

jarosser06 commented Jan 5, 2017

So this is looking for the lambda.json in the CWD so when you are specifying your function path ./ngd but not your config the lambda-uploader is looking in the current working directory and not the ./ngd directory. If you run the command from the function directory or specify the config path it should work.

We usually treat our Python code as a package and put the lambda.json in the root of the project repo.

  • /
  • /lambda.json
  • /function_code

I am hesitant to change the functionality in this since people may be using it this way. Perhaps searching for the config in both the package directory and then the CWD would make more sense. @martinb3 Any thoughts on that?

@gamename
Copy link
Author

gamename commented Jan 5, 2017

@jarosser06 Thanks for the quick reply. Much appreciated.

Yeah, I figured out that I have to pass an explicit path to the json file. Its an added hassle to pass the lambda.json file location, but its manageable.

My Makefile was working like this:

build:
	lambda-uploader --publish ./ngd 

Now it requires:

build:
	lambda-uploader --publish ./ngd \
	                --config ./ngd/lambda.json

Again, that's a bit messier, but I can live with it as long as it works.

@brandond
Copy link
Contributor

FWIW, I would +1 on having it look for lambda.json in the same location as the code being published. If I point it at a folder, I expect it to look there for both code AND configuration. Doesn't make any sense to me that I have to explicitly tell it to look in the same folder for both - especially for simple projects that are just lambda.json and function.py.

@jarosser06
Copy link
Contributor

The reason we did that was because we have a number of large projects where the code is in a specific directory and the config is elsewhere. For smaller projects I agree it probably would make sense to look in the directory passed. To make it backwards compatible I think I'm just going to have it look first in the code directory and then in the CWD.

@jarosser06 jarosser06 self-assigned this Jan 13, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants