otto 2.0.0.pre8 → 2.0.0.pre9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b094c2fc179b84631bf53b1e4b7f3cbcd661f83e1f8a88ab6c1f22d3e8b11cbd
4
- data.tar.gz: 70a7588c86b8b3f31968b577a298f05c09cad5ef5d9fcf028f0feece2963e8fb
3
+ metadata.gz: a99ac23967768247096e9bb9664a9efcc0452ea485496389ff3909209fd12d6c
4
+ data.tar.gz: 209178d26d3b46ddade717d471c8b10755ea6e79a43b8522a5f1d10dfca3d935
5
5
  SHA512:
6
- metadata.gz: c9e8f2f46cf51bc0799dd6030e52a48c1665b9978efb8bc686977be722e61b3c553f17db91d9fd795447b5b4882ac95af404a71e14f9b65d3935a992ecb768f1
7
- data.tar.gz: d0c6f98edf2f468297dcb19bb9743b1a2858f2497cf40d2fc4332550a883542f2b7e1a1de8ac4b9f9d352b40c53e974d6c99aecee2679abc6b38868c02ae5bd6
6
+ metadata.gz: 6d7a07ad3b7b22dbae59038b9edaf26f5db11f041ae808e3c9430a862956a6e874c47afeae3731f1eff7cb065cb38c125c688ea54900e745288d2e17c4462416
7
+ data.tar.gz: 42867d3c6a0d1eb17c440e9b854c826abf5bc0c48b72fa5e76053b00926972a9ba18586f5fbb71f85cb6e5e54426e2c25fff30d77c865fcc21a0e24ab88233de
@@ -36,7 +36,7 @@ jobs:
36
36
  experimental: true
37
37
 
38
38
  steps:
39
- - uses: actions/checkout@v5
39
+ - uses: actions/checkout@v6
40
40
  - name: Set up Ruby
41
41
  uses: ruby/setup-ruby@v1
42
42
  continue-on-error: ${{ matrix.experimental }}
@@ -27,7 +27,7 @@ jobs:
27
27
 
28
28
  steps:
29
29
  - name: Checkout repository
30
- uses: actions/checkout@v5
30
+ uses: actions/checkout@v6
31
31
  with:
32
32
  fetch-depth: 1
33
33
 
@@ -26,7 +26,7 @@ jobs:
26
26
  actions: read # Required for Claude to read CI results on PRs
27
27
  steps:
28
28
  - name: Checkout repository
29
- uses: actions/checkout@v5
29
+ uses: actions/checkout@v6
30
30
  with:
31
31
  fetch-depth: 1
32
32
 
@@ -21,7 +21,7 @@ jobs:
21
21
 
22
22
  steps:
23
23
  - name: Checkout code
24
- uses: actions/checkout@v5
24
+ uses: actions/checkout@v6
25
25
 
26
26
  - name: Set up Ruby
27
27
  uses: ruby/setup-ruby@v1
@@ -88,7 +88,7 @@ jobs:
88
88
 
89
89
  steps:
90
90
  - name: Checkout code
91
- uses: actions/checkout@v5
91
+ uses: actions/checkout@v6
92
92
 
93
93
  - name: Set up Ruby
94
94
  uses: ruby/setup-ruby@v1
data/CHANGELOG.rst CHANGED
@@ -7,6 +7,48 @@ The format is based on `Keep a Changelog <https://keepachangelog.com/en/1.1.0/>`
7
7
 
8
8
  <!--scriv-insert-here-->
9
9
 
10
+ .. _changelog-2.0.0.pre9:
11
+
12
+ 2.0.0.pre9 — 2025-12-06
13
+ =======================
14
+
15
+ Added
16
+ -----
17
+
18
+ - Base HTTP error classes (``Otto::NotFoundError``, ``Otto::BadRequestError``, ``Otto::ForbiddenError``, ``Otto::UnauthorizedError``, ``Otto::PayloadTooLargeError``) that implementing projects can subclass for consistent error handling
19
+ - Auto-registration of all framework error classes during ``Otto#initialize`` - framework errors now automatically return correct HTTP status codes without manual registration
20
+
21
+ Changed
22
+ -------
23
+
24
+ - Framework error classes now inherit from new base classes: ``Otto::Security::AuthorizationError`` < ``Otto::ForbiddenError``, ``Otto::Security::CSRFError`` < ``Otto::ForbiddenError``, ``Otto::Security::RequestTooLargeError`` < ``Otto::PayloadTooLargeError``, ``Otto::Security::ValidationError`` < ``Otto::BadRequestError``, ``Otto::MCP::ValidationError`` < ``Otto::BadRequestError``
25
+ - ``Otto::Security::RequestTooLargeError`` now returns HTTP 413 (Payload Too Large) instead of 500, semantically correct per RFC 7231
26
+
27
+ - Consolidated route handler implementation using Template Method pattern, reducing duplication by ~120 lines while improving maintainability
28
+
29
+ Fixed
30
+ -----
31
+
32
+ - Error handlers now respect route's ``response=json`` parameter for content
33
+ negotiation, ensuring API routes always return JSON error responses regardless
34
+ of the Accept header.
35
+
36
+ - Rate limiters now respect route ``response=json`` declarations when returning
37
+ throttled responses, matching the error handler fix for consistent content
38
+ negotiation across all error paths.
39
+
40
+ - ClassMethodHandler direct testing context now respects route ``response_type``
41
+ when generating error responses.
42
+
43
+ - Unified error handling across ClassMethodHandler and InstanceMethodHandler to consistently support JSON content negotiation
44
+
45
+ AI Assistance
46
+ -------------
47
+
48
+ - Implementation design and architecture developed with AI pair programming
49
+ - Comprehensive test coverage (31 new base class tests, 12 auto-registration tests) developed with AI assistance
50
+ - Error class hierarchy and inheritance patterns refined through AI-guided architectural discussion
51
+
10
52
  .. _changelog-2.0.0.pre8:
11
53
 
12
54
  2.0.0.pre8 — 2025-11-27
@@ -25,53 +67,30 @@ Fixed
25
67
  Added
26
68
  -----
27
69
 
28
- - Error handler registration system for expected business logic errors. Register handlers with ``otto.register_error_handler(ErrorClass, status: 404, log_level: :info)`` to return proper HTTP status codes and avoid logging expected errors as 500s with backtraces. Supports custom response handlers via blocks for complete control over error responses.
70
+ - Error handler registration system for expected business logic errors via ``otto.register_error_handler(ErrorClass, status:, log_level:)``. Supports custom response handlers via blocks.
29
71
 
30
72
  Changed
31
73
  -------
32
74
 
33
- - Backtrace logging now always logs at ERROR level (was DEBUG) with sanitized file paths for security. Backtraces for unhandled 500 errors are always logged regardless of ``OTTO_DEBUG`` setting, with paths sanitized to prevent exposing system information (project files show relative paths, gems show ``[GEM] name-version/path``, Ruby stdlib shows ``[RUBY] filename``).
34
- - Increased backtrace limit from 10 to 20 lines for critical errors to provide better debugging context.
35
-
36
- AI Assistance
37
- -------------
38
-
39
- - Implemented error handler registration architecture with comprehensive test coverage (17 test cases) using sequential thinking to work through security implications and design decisions. AI assisted with path sanitization strategy, error classification patterns, and ensuring backward compatibility with existing error handling.
40
-
41
- Improved backtrace sanitization security and readability
42
- --------------------------------------------------------
43
-
44
- **Security Enhancements:**
75
+ - Backtrace logging now always logs at ERROR level with sanitized file paths (was DEBUG level with full paths)
76
+ - Increased backtrace limit from 10 to 20 lines for better debugging context
77
+ - Improved gem path formatting in backtraces (e.g., ``[GEM] rack/lib/rack.rb:20``)
45
78
 
46
- - Fixed bundler gem path detection to correctly sanitize git-based gems
47
- - Now properly handles nested gem paths like ``/gems/3.4.0/bundler/gems/otto-abc123/``
48
- - Strips git hash suffixes from bundler gems (``otto-abc123def456`` → ``otto``)
49
- - Removes version numbers from regular gems (``rack-3.2.4`` → ``rack``)
50
- - Prevents exposure of absolute paths, usernames, and project names in logs
51
-
52
- **Improvements:**
79
+ Fixed
80
+ -----
53
81
 
54
- - Bundler gems now show as ``[GEM] otto/lib/otto/route.rb:142`` instead of ``[GEM] 3.4.0/bundler/gems/...``
55
- - Regular gems show cleaner output: ``[GEM] rack/lib/rack.rb:20`` instead of ``[GEM] rack-3.2.4/lib/rack.rb:20``
56
- - Multi-hyphenated gem names handled correctly (``active-record-import-1.5.0`` → ``active-record-import``)
57
- - Better handling of version-only directory names in gem paths
82
+ - Fixed path sanitization for bundler git-based gems and multi-hyphenated gem names
58
83
 
59
- **Documentation:**
84
+ Documentation
85
+ -------------
60
86
 
61
- - Added comprehensive backtrace sanitization section to CLAUDE.md
62
87
  - Documented security guarantees and sanitization rules
63
88
  - Added examples showing before/after path transformations
64
- - Created comprehensive test suite for backtrace sanitization
65
89
 
66
- **Rationale:**
67
-
68
- Raw backtraces expose sensitive information:
69
- - Usernames (``/Users/alice/``, ``/home/admin/``)
70
- - Project structure and internal organization
71
- - Gem installation paths and Ruby versions
72
- - System architecture details
90
+ AI Assistance
91
+ -------------
73
92
 
74
- This improvement ensures all backtraces are sanitized automatically, preventing accidental leakage of sensitive system information while maintaining readability for debugging.
93
+ - Implemented error handler registration architecture with comprehensive test coverage (17 test cases) using sequential thinking to work through security implications and design decisions. AI assisted with path sanitization strategy, error classification patterns, and ensuring backward compatibility with existing error handling.
75
94
 
76
95
  .. _changelog-2.0.0.pre6:
77
96
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- otto (2.0.0.pre8)
4
+ otto (2.0.0.pre9)
5
5
  concurrent-ruby (~> 1.3, < 2.0)
6
6
  facets (~> 3.1)
7
7
  ipaddr (~> 1, < 2.0)
@@ -62,7 +62,7 @@ GEM
62
62
  pp (>= 0.6.0)
63
63
  rdoc (>= 4.0.0)
64
64
  reline (>= 0.4.2)
65
- json (2.15.2)
65
+ json (2.16.0)
66
66
  json_schemer (2.4.0)
67
67
  bigdecimal
68
68
  hana (~> 1.3)
@@ -156,21 +156,21 @@ GEM
156
156
  rubocop-ast (>= 1.47.1, < 2.0)
157
157
  ruby-progressbar (~> 1.7)
158
158
  unicode-display_width (>= 2.4.0, < 4.0)
159
- rubocop-ast (1.47.1)
159
+ rubocop-ast (1.48.0)
160
160
  parser (>= 3.3.7.2)
161
161
  prism (~> 1.4)
162
162
  rubocop-performance (1.26.1)
163
163
  lint_roller (~> 1.1)
164
164
  rubocop (>= 1.75.0, < 2.0)
165
165
  rubocop-ast (>= 1.47.1, < 2.0)
166
- rubocop-rspec (3.7.0)
166
+ rubocop-rspec (3.8.0)
167
167
  lint_roller (~> 1.1)
168
- rubocop (~> 1.72, >= 1.72.1)
168
+ rubocop (~> 1.81)
169
169
  rubocop-thread_safety (0.7.3)
170
170
  lint_roller (~> 1.1)
171
171
  rubocop (~> 1.72, >= 1.72.1)
172
172
  rubocop-ast (>= 1.44.0, < 2.0)
173
- ruby-lsp (0.26.2)
173
+ ruby-lsp (0.26.4)
174
174
  language_server-protocol (~> 3.17.0)
175
175
  prism (>= 1.2, < 2.0)
176
176
  rbs (>= 3, < 5)
data/README.md CHANGED
@@ -84,6 +84,26 @@ app = Otto.new("./routes", {
84
84
 
85
85
  Security features include CSRF protection, input validation, security headers, and trusted proxy configuration.
86
86
 
87
+ ## Error Handling
88
+
89
+ Otto provides base error classes that automatically return correct HTTP status codes:
90
+
91
+ ```ruby
92
+ # Use built-in error classes directly
93
+ raise Otto::NotFoundError, "Product not found" # Returns 404
94
+ raise Otto::BadRequestError, "Invalid parameter" # Returns 400
95
+ raise Otto::UnauthorizedError, "Login required" # Returns 401
96
+ raise Otto::ForbiddenError, "Access denied" # Returns 403
97
+
98
+ # Or subclass them for your application
99
+ class MyApp::ResourceNotFound < Otto::NotFoundError; end
100
+
101
+ # Optionally customize status or logging (overrides auto-registration)
102
+ app.register_error_handler(MyApp::ResourceNotFound, status: 410, log_level: :warn)
103
+ ```
104
+
105
+ All framework errors are auto-registered during initialization. No manual registration required unless you want custom behavior.
106
+
87
107
  ## Privacy by Default
88
108
 
89
109
  Otto automatically masks public IP addresses and anonymizes user agents to comply with GDPR, CCPA, and other privacy regulations:
data/docs/.gitignore CHANGED
@@ -3,3 +3,5 @@
3
3
  !migrating/
4
4
  !migrating/*.md
5
5
  !ipaddr-encoding-quirk.md
6
+ !modern-authentication-authorization-landscape.md
7
+ !multi-strategy-authentication-design.md