Skip to content

Add allocation validation for campaign creation #113

@mosoriob

Description

@mosoriob

Problem

Currently, when creating a campaign, users can enter any string for the allocation field and the campaign creation will succeed. However, if the allocation is not valid in the TACC Authentication Service (TAS), the campaign becomes invisible or inaccessible, creating a poor user experience.

Expected Behavior

The system should validate that the provided allocation exists and is accessible to the user before allowing campaign creation to succeed.

Current Implementation

  • Campaign creation accepts any string for allocation field (see app/api/v1/schemas/campaign.py:16)
  • No validation occurs in CampaignService.create_campaign() (app/services/campaign_service.py:12-16)
  • Invalid allocations cause campaigns to be created but not visible to users

Proposed Solution

  1. Add allocation validation to the campaign creation process
  2. Validate against TAS that the allocation exists and user has access
  3. Return appropriate error messages for invalid allocations
  4. Consider adding similar validation for campaign updates

Implementation Notes

  • The PyTAS integration exists in app/pytas/ with Project and Allocation models
  • Validation should occur in the service layer before database persistence
  • Consider caching valid allocations to reduce API calls to TAS

Acceptance Criteria

  • Campaign creation fails with clear error message for invalid allocations
  • Campaign creation succeeds only for valid, accessible allocations
  • Campaign update operations also validate allocations
  • Appropriate error responses are returned to API clients
  • Tests are added to verify allocation validation behavior

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions