Skip to content

Conversation

@alokemajumder
Copy link
Collaborator

Summary

Deep audit uncovered critical bugs that would prevent the application from running. This PR fixes all identified issues.

Critical Fixes

1. Missing Storage Module (CRITICAL)

The codebase imported from storage.factory and storage.base throughout, but the entire storage/ module was missing. Created complete storage module with:

  • storage/base.py: Abstract StorageBackend base class defining the interface
  • storage/factory.py: Factory function create_storage_backend() for instantiating backends
  • storage/local.py: Local filesystem storage backend with async I/O
  • storage/s3.py: S3-compatible storage backend (AWS S3, MinIO)
  • storage/azure.py: Azure Blob Storage placeholder
  • storage/gcs.py: Google Cloud Storage placeholder

2. Type Annotation Bug (api/models/api_key.py)

  • Before: generate_key() -> tuple[str, str]
  • After: generate_key() -> tuple[str, str, str]
  • The function returns 3 values (raw_key, key_hash, key_prefix) but type hint said 2

3. Missing Job Model Columns (api/models/job.py)

Added missing columns that were being referenced by worker/utils/progress.py:

  • current_stage - Alias for stage compatibility
  • status_message - Status message for progress updates
  • updated_at - Last update timestamp
  • processing_stats - JSON field for processing statistics

4. Wrong Column Names (api/services/job_service.py)

  • Changed job.input_url -> job.input_path
  • Changed job.output_url -> job.output_path
  • Added null check for job.operations

Files Changed

  • 10 files changed
  • +820 lines added

Test plan

  • Verify storage backends can be instantiated
  • Test API key generation returns correct tuple
  • Verify Job model migrations
  • Test job service log generation
  • Run application startup without import errors

Critical fixes:
- Created missing storage module with backends:
  - storage/base.py: Abstract StorageBackend base class
  - storage/factory.py: Backend factory function
  - storage/local.py: Local filesystem backend
  - storage/s3.py: S3-compatible backend
  - storage/azure.py: Azure Blob Storage placeholder
  - storage/gcs.py: Google Cloud Storage placeholder

- Fixed api/models/api_key.py:
  - Corrected generate_key() return type annotation to tuple[str, str, str]

- Fixed api/models/job.py:
  - Added missing columns: current_stage, status_message, updated_at, processing_stats

- Fixed api/services/job_service.py:
  - Changed input_url/output_url to input_path/output_path to match Job model
  - Added null check for job.operations
@gensecai-dev gensecai-dev self-requested a review December 7, 2025 18:38
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