Skip to content

Add Team Alerts module #46

Merged
mwirikia merged 32 commits into
mainfrom
keh-1823_add_teams_alert
Apr 29, 2026
Merged

Add Team Alerts module #46
mwirikia merged 32 commits into
mainfrom
keh-1823_add_teams_alert

Conversation

@mwirikia

@mwirikia mwirikia commented Apr 13, 2026

Copy link
Copy Markdown
Contributor

What type of PR is this? (check all applicable)

  • Refactor
  • Feature
  • Bug Fix
  • Optimization
  • Documentation Update

What

This PR includes the following changes:

  • Add the Team Alerts common module, update the vars for it and improve the logging of alerts through Teams Channel.
  • Docs updates for the Lambda/Teams alert Terraform variables and expected Azure secret shape.
  • Consistent auth error handling by preserving HTTPException during token verification.
  • A regression test covering that auth failures remain 401s without sending Teams alerts.
  • CI workflow changes to install the private keh-teams-alert dependency reliably in GitHub Actions.

Testing

Have any new tests been added as part of this issue? If not, try to explain why test coverage is not needed here.

  • Yes
  • No
    Please write a brief description of why test coverage is not necessary here.
  • Not as part of this ticket. (Could be done at a later point)

Documentation

Has any new documentation been written as part of this issue? We should try to keep documentation up to date
as new code is added, rather than leaving it for the future.

  • Yes
  • No
    Please write a brief description of why documentation is not necessary here.
  • Not as part of this ticket. (Could be done at a later point)

Related issues

Provide links to any related issues.

How to review

Describe the steps required to test the changes.

mwirikia added 29 commits April 13, 2026 10:25

@TotalDwarf03 TotalDwarf03 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple of minor nits and a few questions.
I appreciate that this repo is being replaced soon so I'll approve anyway.

The only point I have is that the try-catch sections cover a lot of code. I think in the future, more targeted try-catches should be used. Again, since this is being replaced, that's fine though.

}

# Special case filters
def filter_developed(project):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should these functions remain nested in another or be put somewhere else?

Also, they need docstrings

standard_filters_pass = all(
matches_filter(
get_nested_values(project, paths[key]), filter_params[key]
def filter_source_control(project):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto above

Comment thread aws_lambda_script/app/utils.py Outdated



def get_teams_alert_client() -> Any:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docstring

The return type doesn't seem right. I think it should be TeamsAlertClient | None

Comment thread aws_lambda_script/Dockerfile
Comment thread docs/infrastructure.md Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces Microsoft Teams alerting support for the Tech Audit Tool API, including Terraform wiring and CI/CD updates, while also tightening auth error handling so expected auth failures remain 401s without triggering alert noise.

Changes:

  • Add Teams alert client initialization + alert sending hooks, and preserve HTTPException during auth/token verification.
  • Update Terraform to pass new env vars (Azure secret name, branch gating, environment label) and expand Secrets Manager IAM permissions.
  • Update tests and documentation to reflect new auth behavior, endpoint responses, and required secret/variable shapes; adjust CI/CD build/install flow for the git-based dependency.

Reviewed changes

Copilot reviewed 24 out of 25 changed files in this pull request and generated 12 comments.

Show a summary per file
File Description
testing/test_api.py Updates mocks/patch paths and adds regression tests ensuring auth failures stay 401 and don’t emit Teams alerts.
testing/conftest.py Mocks AWS Secrets Manager/S3 at import time so pytest runs locally without real cloud credentials.
terraform/lambda/variables.tf Adds new Terraform inputs for Teams alert secret + branch/env labeling.
terraform/lambda/main.tf Expands Secrets Manager permissions and injects new env vars into the Lambda.
terraform/lambda/env/prod/example_tfvars.txt Documents azure_secret_name in example tfvars.
terraform/lambda/env/dev/example_tfvars.txt Documents azure_secret_name in example tfvars.
terraform/README.md Documents new Lambda tfvars and expected Azure secret JSON shape.
pyproject.toml Adds keh-teams-alert git dependency for Poetry-managed installs.
poetry.lock Updates lockfile for new dependency set / Poetry version.
docs/infrastructure.md Mirrors Terraform README updates for Teams alert variables/secret shape.
docs/endpoints/user.md Updates /user docs to include groups in response.
docs/endpoints/refresh.md Updates refresh endpoint docs to POST + body shape and response codes.
docs/endpoints/projects.md Updates projects docs and schema fields (supporting tools keys, status codes).
docs/endpoints/project.md Updates project detail docs (behavior + schema + status codes).
docs/endpoints/filter.md Updates filter parameter types/wording and response codes.
docs/endpoints/auth.md Clarifies auth-code exchange endpoint doesn’t require Authorization header.
concourse/scripts/terraform_infra.sh Passes new Terraform vars for Azure secret + branch/env labeling.
concourse/scripts/build_image.sh Passes a GitHub token as a build secret for installing git dependencies during image build.
concourse/ci.yml Adds a failure notification task using Azure credentials and refactors release deploy flow.
aws_lambda_script/requirements.txt Updates pinned runtime deps and adds keh-teams-alert for container builds.
aws_lambda_script/app/utils.py Adds Teams alert client wiring, improved S3 error logging, and env-driven alert gating.
aws_lambda_script/app/resources.py Preserves HTTPException for auth flows and adds alerting on unexpected endpoint failures.
aws_lambda_script/Dockerfile Implements multi-stage build with git-based dependency install using a mounted secret token.
README.md Updates local testing guidance (no real token/AWS creds needed for pytest) and aligns endpoint descriptions.
.github/workflows/ci.yml Updates Poetry version and alters dependency installation behavior for CI.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread concourse/ci.yml
Comment thread .github/workflows/ci.yml Outdated
Comment thread aws_lambda_script/app/resources.py
Comment thread aws_lambda_script/app/resources.py Outdated
Comment thread aws_lambda_script/app/utils.py
Comment thread aws_lambda_script/app/resources.py Outdated
Comment thread aws_lambda_script/app/resources.py
Comment thread aws_lambda_script/app/resources.py
Comment thread terraform/lambda/main.tf Outdated
IMAGE_TAG = var.container_ver
AZURE_SECRET_NAME = var.azure_secret_name
BRANCH_NAME = var.branch_name
AWS_ACCOUNT_NAME = var.domain
Comment thread terraform/lambda/variables.tf
mwirikia and others added 3 commits April 27, 2026 14:32
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@mwirikia mwirikia merged commit c4f1808 into main Apr 29, 2026
4 checks passed
@mwirikia mwirikia deleted the keh-1823_add_teams_alert branch April 29, 2026 13:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants