Error deploying the stage if api mappings are more than 25 in custom domain
- Dominant language
- Python
- Stars
- 11.1k
- Forks
- 1k
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 2
Description
I am getting error while deploying the stage. here is the trace -
Traceback (most recent call last):
File "/home/jenkins/.local/lib/python3.8/site-packages/chalice/cli/__init__.py", line 636, in main
return cli(obj={})
File "/home/jenkins/.local/lib/python3.8/site-packages/click/core.py", line 1130, in __call__
return self.main(*args, **kwargs)
File "/home/jenkins/.local/lib/python3.8/site-packages/click/core.py", line 1055, in main
rv = self.invoke(ctx)
File "/home/jenkins/.local/lib/python3.8/site-packages/click/core.py", line 1657, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/home/jenkins/.local/lib/python3.8/site-packages/click/core.py", line 1404, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/home/jenkins/.local/lib/python3.8/site-packages/click/core.py", line 760, in invoke
return __callback(*args, **kwargs)
File "/home/jenkins/.local/lib/python3.8/site-packages/click/decorators.py", line 26, in new_func
return f(get_current_context(), *args, **kwargs)
File "/home/jenkins/.local/lib/python3.8/site-packages/chalice/cli/__init__.py", line 189, in deploy
deployed_values = d.deploy(config, chalice_stage_name=stage)
File "/home/jenkins/.local/lib/python3.8/site-packages/chalice/deploy/deployer.py", line 376, in deploy
return self._deploy(config, chalice_stage_name)
File "/home/jenkins/.local/lib/python3.8/site-packages/chalice/deploy/deployer.py", line 391, in _deploy
self._sweeper.execute(plan, config)
File "/home/jenkins/.local/lib/python3.8/site-packages/chalice/deploy/sweeper.py", line 46, in execute
self._plan_deletion(remaining, deployed)
File "/home/jenkins/.local/lib/python3.8/site-packages/chalice/deploy/sweeper.py", line 431, in _plan_deletion
resource_data = handler(*handler_args)
File "/home/jenkins/.local/lib/python3.8/site-packages/chalice/deploy/sweeper.py", line 407, in _delete_domain_api_mappings
resource_data = self._delete_api_mapping(
**File "/home/jenkins/.local/lib/python3.8/site-packages/chalice/deploy/sweeper.py", line 197, in _delete_api_mapping
if api_mapping['key'] == '/':
KeyError: 'key'**
I spend couple of days investigating and found the issue after enabling debug flag on deploy. While deploying, chalice makes a call to **_get_api_mappings_** which is returning 25 mappings our of 28. Ideally, all the mappings should be returned. The mapping for the stage which I am deploying is 28th mapping, which isn't returned in the _get_api_mappings_ call, hence, the deployment fails.
The issue is confirmed when I changed '/home/jenkins/.local/lib/python3.8/site-packages/chalice/awsclient.py' and added the maxresults into the call to the function that gets api mappings. It worked. Not sure, how the code assumed 25 as default for maxresults.
This issue should be fixed in the chalice lib. I will suggest to either increase the maxresults count to some larger number or change the logic to read all the mappings for each page.
Contributor guide
Research direction
Start in chalice/awsclient.py at _get_api_mappings_ and inspect how the API mappings response handles the 25-item limit and pagination. Then review chalice/deploy/sweeper.py, especially _delete_api_mapping, and verify that deployment can retrieve and delete all mappings when a custom domain has more than 25.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, python
- Domain
- api, backend, cloud
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100