Skip to content

feat: v0.2.0 - Enterprise Features - #1

Merged
bestend merged 7 commits into
mainfrom
feature/v0.2.0-enterprise-features
Jan 10, 2026
Merged

bestend merged 7 commits into
mainfrom
feature/v0.2.0-enterprise-features

Conversation

@bestend

@bestend bestend commented Jan 10, 2026

Copy link
Copy Markdown
Owner

What is New in v0.2.0

New Features

  • Builder Pattern API - Fluent, chainable API for intuitive app configuration
  • Prometheus Metrics - Built-in /metrics endpoint with request stats
  • Security Headers Middleware - HSTS, CSP, X-Frame-Options out of the box
  • Request ID and Timing - Automatic X-Request-ID and X-Response-Time headers
  • Configuration Management - Centralized Pydantic-based settings

Improvements

  • Updated dependencies to latest versions
  • Status upgraded from Alpha to Beta
  • Expanded test coverage with 6 new test files
  • Added builder example

Documentation

  • Updated README.md and README.ko.md with new features
  • Added comprehensive CHANGELOG for v0.2.0

## New Features
- Builder pattern API for fluent app configuration
- Prometheus-compatible metrics endpoint
- Security headers middleware (HSTS, CSP, X-Frame-Options)
- Request ID and timing middleware
- Centralized configuration management with Pydantic

## Improvements
- Updated dependencies to latest versions
- Status upgraded from Alpha to Beta
- Expanded test coverage with new test files
- Added builder example

## Documentation
- Updated README.md and README.ko.md
- Added CHANGELOG entry for v0.2.0

Copilot AI left a comment

Copy link
Copy Markdown

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 v0.2.0 "Enterprise Features" which adds significant production-ready capabilities to fastapi_bootstrap. The release includes a new fluent Builder Pattern API, Prometheus metrics integration, security headers middleware, centralized configuration management, and request tracking features.

Key Changes:

  • Builder Pattern API with chainable method calls for intuitive application configuration
  • Prometheus-compatible metrics collection and /metrics endpoint
  • Security middleware including HSTS, CSP, X-Frame-Options, request ID, and timing headers
  • Pydantic-based centralized configuration system with environment variable support
  • Comprehensive test coverage with 6 new test files

Reviewed changes

Copilot reviewed 18 out of 19 changed files in this pull request and generated 23 comments.

Show a summary per file
File Description
uv.lock Updated package name from underscore to hyphen convention; version bumped to 0.2.0 with new "all" and "metrics" extras
pyproject.toml Version updated to 0.2.0; status upgraded to Beta; dependencies updated; new keywords and extras added
src/fastapi_bootstrap/init.py Expanded exports to include builder, config, metrics, and middleware modules
src/fastapi_bootstrap/builder.py New fluent builder API with chainable configuration methods
src/fastapi_bootstrap/config.py New Pydantic-based configuration system with environment variable parsing
src/fastapi_bootstrap/metrics.py New Prometheus metrics implementation with Counter, Gauge, Histogram
src/fastapi_bootstrap/middleware/init.py New security and utility middleware classes
tests/test_*.py Six new comprehensive test files for new features
examples/builder/ New example demonstrating builder pattern usage
README.md, README.ko.md Updated documentation with new features and examples
CHANGELOG.md Detailed changelog for v0.2.0 release

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/fastapi_bootstrap/config.py Resolved
Comment thread src/fastapi_bootstrap/config.py Resolved
Comment thread src/fastapi_bootstrap/builder.py Resolved
Comment thread src/fastapi_bootstrap/metrics.py Resolved
Comment thread pyproject.toml Resolved
Comment thread tests/test_logging.py Resolved
Comment thread tests/test_logging.py Resolved
Comment thread tests/test_logging.py Resolved
Comment thread tests/test_logging.py Resolved
Comment thread tests/test_middleware.py Resolved
- MetricsSettings.enabled default: True -> False
- METRICS_ENABLED env default: true -> false
- Metrics only enabled when .with_metrics() is called explicitly
- Fix builder.py: router dependencies now properly passed to include_router
- Fix metrics.py: global registry now supports multiple app_names (dict-based)
- Fix middleware: HSTS header only added for HTTPS connections
- Fix middleware: X-XSS-Protection header now optional (deprecated by default)
- Fix README.ko.md: correct parameter name x_frame_options, remove non-existent from_settings method
- Fix test_metrics.py: correct assertion logic (or -> and)
- Remove unused imports across multiple files (builder, metrics, tests)
- Update middleware tests for HTTPS-only HSTS behavior
@bestend

bestend commented Jan 10, 2026

Copy link
Copy Markdown
Owner Author

📝 Copilot Review Feedback - All Addressed ✅

File Issue Resolution
builder.py Router dependencies ignored ✅ Now passed to include_router()
metrics.py Global registry app_name issue ✅ Dict-based registry per app_name
middleware/__init__.py HSTS added on HTTP ✅ HTTPS only (via scheme/X-Forwarded-Proto)
middleware/__init__.py X-XSS-Protection hardcoded ✅ Now optional (deprecated header)
README.ko.md Non-existent from_settings ✅ Removed
README.ko.md Wrong param frame_options ✅ Fixed to x_frame_options
test_metrics.py Assertion logic (or vs and) ✅ Fixed
Multiple files Unused imports ✅ Removed

Commit: 893456b
Tests: 161 passed ✅
Coverage: 85%

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 18 out of 19 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/fastapi_bootstrap/metrics.py Resolved
- Fix histogram bucket counting bug: only increment smallest matching bucket
- Add error handling for integer environment variable parsing in config.py
- Add CORS allow_credentials=True with origins=['*'] warning
- Fix README.md package name: fastapi_bootstrap -> fastapi-bootstrap
- Fix unused response variable in test_builder.py
@bestend

bestend commented Jan 10, 2026

Copy link
Copy Markdown
Owner Author

추가 리뷰 피드백 반영 완료 ✅

커밋 6711ec9에서 추가 리뷰 코멘트들을 반영했습니다:

수정 사항

  1. Histogram bucket counting 버그 수정 (metrics.py)

    • observe() 메서드에서 모든 매칭 버킷이 아닌 가장 작은 버킷만 증가하도록 수정
    • break 문 추가로 double-counting 문제 해결
    • 더 명확한 docstring 추가
  2. 환경변수 정수 파싱 에러 핸들링 (config.py)

    • parse_int_env() 헬퍼 함수 추가
    • 잘못된 정수 값에 대해 명확한 ValueError 발생
  3. CORS 보안 경고 추가 (config.py)

    • allow_credentials=True + origins=["*"] 조합에 대해 경고 출력
    • 프로덕션에서 명시적 origin 설정 권장
  4. README.md 패키지명 수정

    • pip install fastapi_bootstrap → pip install fastapi-bootstrap
    • PyPI 표준 패키지명 (하이픈) 사용
  5. test_builder.py 미사용 변수 수정

    • response 변수를 인라인 assertion으로 변경

모든 161개 테스트 통과, 커버리지 85% 유지됩니다. 🎉

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 18 out of 19 changed files in this pull request and generated 17 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/fastapi_bootstrap/config.py Resolved
Comment thread src/fastapi_bootstrap/metrics.py Resolved
Comment thread src/fastapi_bootstrap/builder.py Resolved
Comment thread pyproject.toml Resolved
Comment thread src/fastapi_bootstrap/builder.py Resolved
Comment thread src/fastapi_bootstrap/metrics.py Resolved
Comment thread src/fastapi_bootstrap/config.py Resolved
Comment thread src/fastapi_bootstrap/metrics.py Resolved
Comment thread src/fastapi_bootstrap/builder.py Resolved
- Fix error double-counting bug in metrics.py (if-elif instead of if-or)
- Document chunked transfer encoding limitation in MaxRequestSizeMiddleware
- Document mask_sensitive_data implicit dependency on get_settings()
- Document router property preservation limitation in builder.py
- Add test cache isolation in test_config.py
- Add package naming clarification in pyproject.toml
@bestend

bestend commented Jan 10, 2026

Copy link
Copy Markdown
Owner Author

2차 리뷰 피드백 반영 완료 ✅

커밋 97cd12d에서 새로운 리뷰 코멘트들을 반영했습니다:

수정 사항

  1. 에러 더블 카운팅 버그 수정 (metrics.py:380-383)

    • if-or → if-elif 구조로 변경
    • exception과 5xx 에러가 중복 카운트되지 않음
  2. MaxRequestSizeMiddleware 제한사항 문서화 (middleware/__init__.py)

    • chunked transfer encoding에 대한 제한 사항 명시
    • reverse proxy 사용 권장 추가
  3. mask_sensitive_data 암묵적 의존성 문서화 (config.py)

    • get_settings() 호출 동작 명시
    • 독립적 사용 시 명시적 필드 제공 권장
  4. Router 속성 보존 제한사항 문서화 (builder.py)

    • prefix/dependencies 사용 시 라우트 복사 동작 명시
    • 복잡한 설정 시 직접 include_router 사용 권장
  5. 테스트 캐시 격리 (test_config.py:126)

    • test_from_env_cors_origins에 cache_clear() 추가
  6. 패키지명 설명 주석 (pyproject.toml)

    • underscore/hyphen 명명 규칙 설명 추가

모든 161개 테스트 통과, 85% 커버리지 유지 🎉

- CORS allow_credentials + wildcard now raises ValueError (not just warning)
- Improved validate_level error message with original and normalized values
- Added model_validator for json_output/format consistency warning
- Enhanced X-XSS-Protection deprecation documentation
- Optimized _get_path_template to use scope['route'] cache first
- Added thread-safe lock to _metrics_registries access
- Fixed test_with_health_check to properly verify endpoint
@bestend

bestend commented Jan 10, 2026

Copy link
Copy Markdown
Owner Author

3차 리뷰 피드백 반영 완료 ✅

커밋 7310f71에서 추가 리뷰 코멘트들을 반영했습니다:

주요 수정 사항

  1. CORS 검증 강화 (config.py:340-347)

    • allow_credentials=True + origins=['*'] 조합 → ValueError 발생
    • CORS 스펙에 따라 브라우저가 거부하는 설정을 사전에 차단
  2. 에러 메시지 개선 (config.py:86)

    • validate_level: 원본값과 정규화된 값 모두 표시
    • 디버깅 용이성 향상
  3. Deprecated 필드 검증 (config.py:92-101)

    • json_output=True + format=TEXT 불일치 시 DeprecationWarning 발생
    • model_validator 사용
  4. X-XSS-Protection 문서화 강화 (middleware/__init__.py)

    • Chrome 78+, Edge 79+, Firefox 70+에서 제거됨 명시
    • CSP 사용 권장 안내
  5. Path Template 성능 최적화 (metrics.py:333-351)

    • request.scope['route'] 캐시 먼저 확인
    • 불필요한 route 순회 제거
  6. Thread Safety 강화 (metrics.py:275-298)

    • _metrics_registries에 Lock 추가
    • Double-checked locking 패턴 적용
  7. 테스트 개선 (test_builder.py:72-81)

    • test_with_health_check 정확한 검증으로 수정

참고 (향후 개선 고려)

  • parse_int_env 함수 모듈 레벨 추출 - 현재 from_env 내부 유지
  • build() 내 stage 변환 중복 - 가독성 위해 현재 유지
  • MetricsMiddleware exclude_paths 동적화 - 향후 버전에서 고려
  • build() 내 조건부 import - 성능 영향 미미하여 현재 유지

모든 161개 테스트 통과, 85% 커버리지 🎉

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 18 out of 19 changed files in this pull request and generated 6 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/test_metrics.py Resolved
Comment thread src/fastapi_bootstrap/metrics.py Resolved
Comment thread src/fastapi_bootstrap/metrics.py Resolved
Comment thread pyproject.toml Resolved
Comment thread src/fastapi_bootstrap/builder.py Resolved
Comment thread src/fastapi_bootstrap/metrics.py Resolved
- Fix Histogram _counts sharing bug (use dict factory + __post_init__)
- Store and pass header_name params in with_request_id/with_request_timing
- Update test_bucket_counts assertions to be exact (not >=)
- Change pyproject.toml name to hyphen convention (fastapi-bootstrap)
- Add chunked transfer encoding note to MaxRequestSizeMiddleware docs
@bestend

bestend commented Jan 10, 2026

Copy link
Copy Markdown
Owner Author

4차 리뷰 피드백 반영 완료 (commit f4b3c01)

수정 사항

이슈 수정 내용
Histogram _counts 공유 버그 field(default_factory=dict) + __post_init__으로 인스턴스별 독립적인 dict 생성
header_name 파라미터 미사용 _request_id_header, _request_timing_header 저장 후 middleware에 전달
test_bucket_counts 검증 >= → ==로 변경하여 정확한 cumulative 검증
pyproject.toml 패키지명 fastapi_bootstrap → fastapi-bootstrap (PyPI 컨벤션)

설계 의도 설명 (변경 없음)

  • status_code 기본값 500: 처리되지 않은 예외의 의도된 동작. exception handler가 다른 status code를 반환하면 response.status_code로 올바르게 캡처됨

✅ 161개 테스트 통과 | 📊 85% 커버리지

@bestend
bestend merged commit 2249f28 into main Jan 10, 2026
2 checks passed
@bestend
bestend deleted the feature/v0.2.0-enterprise-features branch January 10, 2026 04:00
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