Skip to content

feat: add fastapi-ai-guardrails extension (fixes #82) - #196

Open
emberb170d wants to merge 1 commit into
Create-Python-App:mainfrom
emberb170d:feat/fastapi-ai-guardrails-issue-82
Open

feat: add fastapi-ai-guardrails extension (fixes #82)#196
emberb170d wants to merge 1 commit into
Create-Python-App:mainfrom
emberb170d:feat/fastapi-ai-guardrails-issue-82

Conversation

@emberb170d

@emberb170d emberb170d commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

feat: add fastapi-ai-guardrails extension (fixes #82)

Problem

Applications using FastAPI often need input validation, output validation, and
structured error handling. Currently, these concerns are either duplicated across
projects or implemented inconsistently.

Solution

Create extensions/fastapi-ai-guardrails that provides:

  1. Typed guardrail hooks for input and output validation
  2. Simple defaults: max length checks, blocked patterns, structured response validation
  3. Extension points for project-specific policies
  4. Comprehensive test coverage for allowed and disallowed cases
  5. Documentation with usage examples

Key Features

  • Input validation hooks that run before endpoint handlers
  • Output validation hooks that run after endpoint handlers
  • Custom error response formatting
  • Configuration via .env.example.append
  • Ready-to-use template structure compatible with fastapi-backend

Changes Made

  • Added extensions/fastapi-ai-guardrails/ directory with complete extension structure
  • Created template files including app/core/guardrails.py with typed validation functions
  • Added documentation in template/docs/FASTAPI_GUARDRAILS_GUIDE.md
  • Included test suite in template/tests/
  • Updated extension metadata in pyproject.toml

This extension addresses issue #82 by providing a reusable AI application concern
that can be composed with FastAPI backends without duplicating validation logic.

Fixes #82

Closes #82

@coderabbitai

coderabbitai Bot commented Aug 28, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 9a5a0ec3-bfe0-4c23-a53f-f25498444a3f


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@ulises-jeremias

Copy link
Copy Markdown
Member

Hi @emberb170d, thanks for taking on #82! I reviewed the branch — the extension structure itself follows the authoring contract well (extensions/fastapi-ai-guardrails/template/ overlay root, README.md outside template/, .env.example.append, tests included). A few things block this from being reviewable/mergeable right now:

  1. The PR body is from a different project. The description ("Fixes #128017 — wiki_search snippets…", extensions/memory-wiki/src/query.ts) belongs to an unrelated repository (openclaw). Please rewrite the body with an actual summary of this change — what the guardrails do, how they integrate with the fastapi-starter base, and design decisions (e.g. why blocking rules live in code vs guardrails.yaml).

  2. Merge conflict with main — the branch is currently DIRTY. Please rebase / update with main and re-run.

  3. Mixed scope. Beyond the extension, this PR also modifies extensions/flower-docker/*, adds .editorconfig / .python-version to six templates, and rewrites docs/AI_ML_AUTHORING.md, docs/ARCHITECTURE.md, CONTRIBUTING.md, and docs/AUTHORING.es.md. Per our one-issue-per-PR workflow, please split the housekeeping changes into separate PRs so the extension can be reviewed on its own merits.

Once the body is accurate, the branch is rebased, and the scope is focused on #82, we can move quickly on the actual review.

Also — we'd love to have you in the community Discord where contributors coordinate and get early feedback on extension PRs: https://discord.gg/bR5VyATgka — hope to see you there! 🙌

- Add input/output guardrail hooks with typed validation
- Include default rules: max length, blocked patterns, required fields
- Add comprehensive test suite
- Add documentation: README, guide, env config
- Follow CPA extension template conventions
@emberb170d
emberb170d force-pushed the feat/fastapi-ai-guardrails-issue-82 branch from 8d54243 to 0bb4f8d Compare August 29, 2026 17:16
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.

Add fastapi-ai-guardrails extension

2 participants