Skip to content

Conversation

@exp0nge
Copy link

@exp0nge exp0nge commented Jun 14, 2025

This adds the ability to define 'Reason' templates.

It allows organizations to define expected fields for requesting access to standardize requests across teams.

Two new fields are added:

  • REASON_TEMPLATE: The template to use and is the default value.
    • Example: "Project: [Project Name]\nTicket: [Ticket ID]\nJustification: [Why is this access needed?]",
  • REASON_TEMPLATE_REQUIRED : The fields that must be present in the reason. This allows the template to define helpful context while this is the hard required text that must exist in the reason.
    • ["Project", "Ticket", "Justification"]

Screenshots of the feature:
View:
Screenshot 2025-06-14 at 7 00 13 PM

Error screen:
Screenshot 2025-06-14 at 7 00 24 PM

Copilot AI review requested due to automatic review settings June 14, 2025 23:48

This comment was marked as outdated.

@exp0nge exp0nge force-pushed the md-reason-teamplte branch 2 times, most recently from 25c93b4 to 92b2f65 Compare June 15, 2025 03:03
@exp0nge exp0nge requested a review from Copilot June 15, 2025 03:03
Copy link
Contributor

Copilot AI left a comment

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 reason templates for access requests to standardize and enforce required fields in user-provided reasons. Key changes include:

  • Adding new configuration options (REASON_TEMPLATE and REASON_TEMPLATE_REQUIRED) in the frontend and backend.
  • Implementing validation logic on both API and UI to prevent submission of templated or incomplete reasons.
  • Creating tests to cover various invalid and valid reason scenarios.

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tests/test_reason_template.py Adds tests to validate correct and incorrect reason template behaviors.
src/pages/role_requests/Create.tsx Updates the UI to use the REASON_TEMPLATE as a placeholder.
src/pages/requests/Create.tsx Enhances form validation to check for both templated and missing fields.
src/config/loadAccessConfig.js Loads new config options ensuring consistency between template options.
src/config/accessConfig.ts Updates type definitions to include reason template options.
api/views/schemas/access_requests.py Implements API validation logic for the reason field using the new config.
api/operations/constraints/check_for_reason.py Updates constraint logic to reject unmodified or incomplete reason entries.
api/access_config.py Updates access configuration parsing to include the new template options.
Comments suppressed due to low confidence (2)

api/views/schemas/access_requests.py:30

  • Consider aggregating missing required fields into a comprehensive error message (e.g., listing all fields) instead of raising an error on the first missing field, to provide clear guidance to the API consumer.
for required_field in access_config.reason_template_required:

api/operations/constraints/check_for_reason.py:58

  • Consider aggregating and reporting all missing required fields in the reason instead of returning after detecting the first missing field, to align with the frontend validation logic and improve error messaging.
for required_field in access_config.reason_template_required:

@exp0nge exp0nge force-pushed the md-reason-teamplte branch from 92b2f65 to d0cedff Compare June 15, 2025 03:06
@exp0nge exp0nge force-pushed the md-reason-teamplte branch from d0cedff to 37e1166 Compare June 15, 2025 03:31
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.

1 participant