Skip to content

Migrate config to Pydantic, fix datetime deprecation, add import guards#8

Merged
JustAGhosT merged 3 commits intotembo/refactor-codebase-structurefrom
copilot/sub-pr-7
Dec 23, 2025
Merged

Migrate config to Pydantic, fix datetime deprecation, add import guards#8
JustAGhosT merged 3 commits intotembo/refactor-codebase-structurefrom
copilot/sub-pr-7

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Dec 23, 2025

Addressed code review feedback requiring config validation, timezone-aware timestamps, and graceful degradation for optional dependencies.

Config Models → Pydantic

Migrated dataclass configs to Pydantic BaseModel with validation:

# Before: No validation, secrets exposed in logs
@dataclass
class LLMConfig:
    api_key: str | None = None
    temperature: float = 0.7
    max_tokens: int = 4096

# After: Validated, secrets redacted
class LLMConfig(BaseModel):
    api_key: SecretStr | None = None
    temperature: float = Field(default=0.7, ge=0.0, le=2.0)
    max_tokens: int = Field(default=4096, gt=0)
  • DatabaseConfig/RedisConfig: URL format validation (requires ://)
  • LLMConfig: temperature ∈ [0.0, 2.0], max_tokens > 0
  • WorkflowConfig: max_concurrent > 0, retry_attempts ≥ 0
  • GitHubConfig: SecretStr for token, private_key, webhook_secret

Datetime Deprecation

Replaced datetime.utcnow() with datetime.now(timezone.utc):

# base.py, events.py
created_at: datetime = field(default_factory=lambda: datetime.now(timezone.utc))

All timestamps now timezone-aware (UTC).

Import Guards

Made optional dependency imports failsafe:

# Category modules degrade gracefully
ai_actions = None
try:
    from codeflow_engine.actions import ai_actions
except (ImportError, OSError):
    pass
  • Added FindStaleIssuesOrPRs to guarded exports
  • Wrapped autogen, llm submodule imports
  • Guarded EnterpriseAuthorizationManager import
  • All category modules (ai_actions, platform, quality, etc.) now optional

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Dec 23, 2025

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copilot AI and others added 2 commits December 23, 2025 21:38
- Migrate config.py from dataclasses to Pydantic BaseModel with comprehensive validation
  - Add URL validation for DatabaseConfig and RedisConfig
  - Add temperature bounds (0.0-2.0) and max_tokens validation for LLMConfig
  - Add positive integer validation for WorkflowConfig
  - Mark secret fields (api_key, token, private_key, webhook_secret) as SecretStr
- Replace deprecated datetime.utcnow() with timezone-aware datetime.now(timezone.utc)
  - Fixed in base.py (BaseModel and TimestampMixin)
  - Fixed in events.py (WebhookEvent)
- Add FindStaleIssuesOrPRs to guarded imports in actions/issues/__init__.py
- Add guarded imports for ai_actions submodules (autogen, llm)
- Make EnterpriseAuthorizationManager import guarded in __init__.py
- Make all category module imports in actions/__init__.py guarded for graceful degradation

Co-authored-by: JustAGhosT <5531814+JustAGhosT@users.noreply.github.com>
Field constraints already handle validation, no need for duplicate validators

Co-authored-by: JustAGhosT <5531814+JustAGhosT@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor CodeFlow Engine package structure Migrate config to Pydantic, fix datetime deprecation, add import guards Dec 23, 2025
Copilot AI requested a review from JustAGhosT December 23, 2025 21:44
@JustAGhosT JustAGhosT marked this pull request as ready for review December 23, 2025 21:46
@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@JustAGhosT JustAGhosT merged commit fd743a0 into tembo/refactor-codebase-structure Dec 23, 2025
1 check was pending
@JustAGhosT JustAGhosT deleted the copilot/sub-pr-7 branch December 23, 2025 21:46
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.

2 participants