jlhood / github-codebuild-logs

Serverless App that publishes CodeBuild build logs to a publicly accessible location
MIT License
88 stars 22 forks source link

Builds not created by PRs result in an error #2

Closed mattsb42 closed 5 years ago

mattsb42 commented 5 years ago

When a CodeBuild build is triggered by something other than a PR (ex: manually), the sourceVersion field might not be present in the build details.

Because this field is currently retrieved by a getitem call[1], if the key is not found, a KeyError is thrown[2].

[1] https://github.com/jlhood/github-codebuild-logs/blob/master/src/build.py#L27-L32 [2]

[ERROR] KeyError: 'sourceVersion'
Traceback (most recent call last):
  File "/var/task/processbuildevents.py", line 29, in handler
    if not build.is_pr_build():
  File "/var/task/build.py", line 36, in is_pr_build
    return self.get_pr_id() is not None
  File "/var/task/build.py", line 29, in get_pr_id
    matches = re.match(r'^pr\/(\d+)', self._get_build_details()['sourceVersion'])
jlhood commented 5 years ago

@mattsb42 Thanks for reporting. This should be an easy fix.

jlhood commented 5 years ago

PR has been merged. Will be available in v1.1.0, but publishing to SAR is delayed. ETA for the new release is 10/9.

jlhood commented 5 years ago

Fixed in v1.1.0 (now released and published to SAR)