fix(safe-deploy): query correct CF API endpoint for per-env worker binding audit#257
fix(safe-deploy): query correct CF API endpoint for per-env worker binding audit#257chitcommit wants to merge 5 commits into
Conversation
…nding audit
Wrangler v4 deploys --env workers as standalone scripts (e.g.
chittyconnect-staging), not as service-environment pairs. The post-deploy
audit was curling the legacy services/chittyconnect/environments/staging
endpoint, which returns CF error 10092 ("environment does not exist")
because that service object never exists in the per-env-worker model.
Fix: switch to the /workers/scripts/{DEPLOYED_NAME}/bindings endpoint,
where DEPLOYED_NAME is already computed correctly (chittyconnect-staging
for staging, chittyconnect for production). Validated live against
chittyconnect-staging: returns 74 bindings, HTTP 200, result[].name shape
unchanged. The fail-loud binding-drift logic (exit 72 on missing names)
is fully preserved — only the lookup target changes.
Unblocks Workers Builds check on all chittyconnect PRs (including #252/#253).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
chittyconnect | a1a4648 | Jun 16 2026, 09:06 PM |
📝 WalkthroughWalkthroughThis PR completes several production-readiness items: ChangesProduction Hardening
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related issues
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Pull request overview
This PR updates deployment safety tooling and runtime observability/reliability features across ChittyConnect, including a fix for the post-deploy Cloudflare bindings audit endpoint and broader runtime changes (rate limiting, Sentry wrapping, resilient fetch adoption).
Changes:
- Fix
scripts/safe-deploy.shbinding audit to query the correct Cloudflare Workers API endpoint for per-env workers (workers/scripts/<deployed_name>/bindings). - Enable global rate limiting middleware and wrap the Worker export with Sentry (
@sentry/cloudflare). - Enhance
resilientFetcherror reporting and add Vitest coverage; migrate ChittyOS ecosystem service calls fromfetchtoresilientFetch.
Reviewed changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/utils/error-handling.test.js | Adds Vitest coverage for error classification, retry/backoff, and circuit breaker behavior. |
| STATUS.md | Updates roadmap checkboxes to reflect completion of rate limiting, monitoring, and resilient fetch wrapping. |
| src/utils/error-handling.js | Improves resilientFetch error messages by attempting to include response body text. |
| src/integrations/chittyos-ecosystem.js | Switches multiple internal service calls from fetch to resilientFetch. |
| src/index.js | Enables global rate limiting and wraps the Worker handler with Sentry configuration. |
| scripts/safe-deploy.sh | Fixes CF API endpoint used by the binding audit for per-env workers. |
| package.json | Adds @sentry/cloudflare dependency. |
| package-lock.json | Locks the new Sentry dependency and transitive packages. |
Comments suppressed due to low confidence (7)
src/integrations/chittyos-ecosystem.js:159
resilientFetch()already throws on non-2xx responses, so the subsequentif (!response.ok)block below this call is now unreachable and can be removed to avoid dead code and duplicated error handling.
const response = await resilientFetch(`${this.baseUrls.registry}/api/services`, {
headers: {
Authorization: `Bearer ${this.env.CHITTY_REGISTRY_TOKEN}`,
"Content-Type": "application/json",
},
src/integrations/chittyos-ecosystem.js:192
- Because this call now uses
resilientFetch(), non-2xx responses will throw before returning aresponse. Theif (!response.ok)block (andawait response.text()) below becomes dead code and should be removed.
const response = await resilientFetch(`${this.baseUrls.chittyid}/v1/mint`, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${this.env.CHITTY_ID_TOKEN}`,
src/integrations/chittyos-ecosystem.js:225
- With
resilientFetch()here, non-OK responses are thrown as errors, so the manualif (!response.ok)check below is unreachable and can be removed to keep behavior consistent and avoid maintaining duplicate error paths.
const response = await resilientFetch(`${this.baseUrls.dna}/api/initialize`, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${this.env.CHITTY_DNA_TOKEN}`,
src/integrations/chittyos-ecosystem.js:273
- This uses
resilientFetch(), which throws on non-2xx responses, so theif (!response.ok)block below is dead code now. Removing it reduces duplication and avoids relying on reading the body twice.
const response = await resilientFetch(`${this.baseUrls.auth}/api/keys/provision`, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${authToken}`,
src/integrations/chittyos-ecosystem.js:319
- Since this now calls
resilientFetch(), non-OK responses will throw and never return aresponse, making theif (!response.ok)block below unreachable. Removing the dead code keeps the error handling centralized inresilientFetch().
const response = await resilientFetch(
`${this.baseUrls.registry}/api/services/register`,
{
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${this.env.CHITTY_REGISTRY_TOKEN}`,
},
src/integrations/chittyos-ecosystem.js:356
- With
resilientFetch()here, non-2xx responses throw before returning, so the manualif (!response.ok)block below is unreachable and can be removed to avoid duplicated error handling.
const response = await resilientFetch(
`${this.baseUrls.verify}/api/verify/context`,
{
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${this.env.CHITTY_VERIFY_TOKEN}`,
"X-ChittyID": chittyid,
src/integrations/chittyos-ecosystem.js:396
- Because this uses
resilientFetch(), theif (!response.ok)block below is now unreachable (non-OK responses already throw). Removing it prevents dead code and keeps error messages consistent.
const response = await resilientFetch(
`${this.baseUrls.certify}/api/certify/context`,
{
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${this.env.CHITTY_CERTIFY_TOKEN}`,
"X-ChittyID": chittyid,
},
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if (!response.ok) { | ||
| let errorText = ""; | ||
| try { | ||
| errorText = await response.text(); | ||
| } catch (e) {} | ||
| const error = new Error( | ||
| `HTTP ${response.status}: ${response.statusText}`, | ||
| `HTTP ${response.status}: ${response.statusText}${errorText ? ' - ' + errorText : ''}`, | ||
| ); |
| (env) => ({ | ||
| dsn: env.SENTRY_DSN || "", | ||
| tracesSampleRate: 1.0, | ||
| }), |
| async fetch(request, env, ctx) { | ||
| const url = new URL(request.url); | ||
| const host = (url.hostname || "").toLowerCase(); |
| // Rate Limiting Middleware | ||
| app.use("*", rateLimitMiddleware); |
| "@cloudflare/workers-oauth-provider": "^0.2.2", | ||
| "@modelcontextprotocol/sdk": "^1.25.2", | ||
| "@neondatabase/serverless": "^0.10.4", | ||
| "@sentry/cloudflare": "^10.58.0", | ||
| "agents": "^0.7.5", |
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (9)
src/index.js (2)
2472-2472:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winUnused
ctxparameter flagged by ESLint.Prefix with underscore to satisfy the linter convention.
🔧 Proposed fix
- async scheduled(event, env, ctx) { + async scheduled(event, env, _ctx) {🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/index.js` at line 2472, The scheduled method parameter ctx is flagged by ESLint as unused. To satisfy the linter convention for intentionally unused parameters, rename the ctx parameter to _ctx in the scheduled method signature (where it appears alongside event and env parameters).Source: Pipeline failures
2161-2176:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winUnused function flagged by ESLint.
stripRedirectUriQueryParamsis defined but never called. The function body references it nowhere in the file. Either remove it or prefix with_to satisfy the linter.🔧 Proposed fix
-function stripRedirectUriQueryParams(request) { +function _stripRedirectUriQueryParams(request) {Or remove the function entirely if it's dead code.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/index.js` around lines 2161 - 2176, The function stripRedirectUriQueryParams is defined but never called in the codebase, causing an ESLint unused function warning. Either remove the entire stripRedirectUriQueryParams function if it is indeed dead code, or rename it to _stripRedirectUriQueryParams by prefixing with an underscore if it needs to be retained for future use or reference purposes.Source: Pipeline failures
src/integrations/chittyos-ecosystem.js (7)
240-245: 🛠️ Refactor suggestion | 🟠 Major | ⚡ Quick winRemove unreachable error handling code.
The
if (!response.ok)check is dead code—resilientFetchalready throws for non-OK responses, so this block never executes.♻️ Remove the unreachable block
const response = await resilientFetch(`${this.baseUrls.dna}/api/initialize`, { method: "POST", headers: { "Content-Type": "application/json", Authorization: `Bearer ${this.env.CHITTY_DNA_TOKEN}`, "X-ChittyID": chittyid, }, body: JSON.stringify({ chittyid, type: "context", metadata, genesis: { service: "chittyconnect", timestamp: new Date().toISOString(), genesisSchemaVersion: "1.0.0", }, }), }); - if (!response.ok) { - const error = await response.text(); - throw new Error( - `ChittyDNA initialization failed: ${response.status} - ${error}`, - ); - } - const dna = await response.json();🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/integrations/chittyos-ecosystem.js` around lines 240 - 245, The if (!response.ok) block is unreachable code because resilientFetch already throws an error for non-OK responses before returning, so the response object will never have an ok property set to false. Remove the entire if block that checks !response.ok and throws the error in the ChittyDNA initialization section, as this error handling is already handled by the resilientFetch function itself.
401-406: 🛠️ Refactor suggestion | 🟠 Major | ⚡ Quick winRemove unreachable error handling code.
The
if (!response.ok)check is dead code—resilientFetchalready throws for non-OK responses, so this block never executes.♻️ Remove the unreachable block
const response = await resilientFetch( `${this.baseUrls.certify}/api/certify/context`, { method: "POST", headers: { "Content-Type": "application/json", Authorization: `Bearer ${this.env.CHITTY_CERTIFY_TOKEN}`, "X-ChittyID": chittyid, }, body: JSON.stringify(certificationData), }, ); - if (!response.ok) { - const error = await response.text(); - throw new Error( - `Context certification failed: ${response.status} - ${error}`, - ); - } - const certification = await response.json();🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/integrations/chittyos-ecosystem.js` around lines 401 - 406, The `if (!response.ok)` block is unreachable because `resilientFetch` already throws an error for non-OK HTTP responses before returning, so this error handling code never executes. Remove the entire `if (!response.ok)` block including the response.text() call and the thrown Error, keeping only the code that follows after this conditional block.
362-367: 🛠️ Refactor suggestion | 🟠 Major | ⚡ Quick winRemove unreachable error handling code.
The
if (!response.ok)check is dead code—resilientFetchalready throws for non-OK responses, so this block never executes.♻️ Remove the unreachable block
const response = await resilientFetch( `${this.baseUrls.verify}/api/verify/context`, { method: "POST", headers: { "Content-Type": "application/json", Authorization: `Bearer ${this.env.CHITTY_VERIFY_TOKEN}`, "X-ChittyID": chittyid, }, body: JSON.stringify(verificationData), }, ); - if (!response.ok) { - const error = await response.text(); - throw new Error( - `Context verification failed: ${response.status} - ${error}`, - ); - } - const verification = await response.json();🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/integrations/chittyos-ecosystem.js` around lines 362 - 367, The if (!response.ok) block starting after the resilientFetch call is dead code that will never execute because resilientFetch already throws an error for non-OK responses. Remove the entire conditional block containing the response.ok check, the error text extraction, and the throw statement. The remaining code after this block can proceed without this redundant error handling.
197-202: 🛠️ Refactor suggestion | 🟠 Major | ⚡ Quick winRemove unreachable error handling code.
The
if (!response.ok)check is dead code—resilientFetchalready throws for non-OK responses, so this block never executes.♻️ Remove the unreachable block
const response = await resilientFetch(`${this.baseUrls.chittyid}/v1/mint`, { method: "POST", headers: { "Content-Type": "application/json", Authorization: `Bearer ${this.env.CHITTY_ID_TOKEN}`, }, body: JSON.stringify(args), }); - if (!response.ok) { - const error = await response.text(); - throw new Error( - `ChittyID minting failed: ${response.status} - ${error}`, - ); - } - const result = await response.json();🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/integrations/chittyos-ecosystem.js` around lines 197 - 202, The `if (!response.ok)` block is unreachable dead code because the `resilientFetch` function already throws an error for non-OK responses, so execution never reaches this check. Remove the entire if statement block (the condition check and the error throwing logic inside it) from the ChittyID minting code, keeping only the code that executes after a successful response.
162-164: 🛠️ Refactor suggestion | 🟠 Major | ⚡ Quick winRemove unreachable error handling code.
The
if (!response.ok)check at line 162 is dead code becauseresilientFetchalready throws when the response is not OK (seesrc/utils/error-handling.jslines 329-340). This block will never execute. The same issue appears in multiple methods throughout this file.♻️ Remove the unreachable block
const response = await resilientFetch(`${this.baseUrls.registry}/api/services`, { headers: { Authorization: `Bearer ${this.env.CHITTY_REGISTRY_TOKEN}`, "Content-Type": "application/json", }, }); - if (!response.ok) { - throw new Error(`Registry discovery failed: ${response.status}`); - } - const services = await response.json();🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/integrations/chittyos-ecosystem.js` around lines 162 - 164, Remove the unreachable error handling block that checks if (!response.ok). This block is dead code because the resilientFetch function already throws an error when the response is not OK, so the code after the fetch call will never execute if the response status is not OK. Delete the entire if block that throws the error with the message about Registry discovery failed.
279-284: 🛠️ Refactor suggestion | 🟠 Major | ⚡ Quick winRemove unreachable error handling code.
The
if (!response.ok)check is dead code—resilientFetchalready throws for non-OK responses, so this block never executes.♻️ Remove the unreachable block
const response = await resilientFetch(`${this.baseUrls.auth}/api/keys/provision`, { method: "POST", headers: { "Content-Type": "application/json", Authorization: `Bearer ${authToken}`, "X-ChittyID": chittyid, }, body: JSON.stringify(keyParams), }); - if (!response.ok) { - const error = await response.text(); - throw new Error( - `API key provisioning failed: ${response.status} - ${error}`, - ); - } - const keys = await response.json();🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/integrations/chittyos-ecosystem.js` around lines 279 - 284, The if (!response.ok) block that checks the response status and throws an error is unreachable dead code because resilientFetch already throws an exception for non-OK responses. Simply delete the entire if block that checks !response.ok, along with the const error declaration and error throwing logic. The code that follows this block will execute normally without this redundant error handling.
324-329: 🛠️ Refactor suggestion | 🟠 Major | ⚡ Quick winRemove unreachable error handling code.
The
if (!response.ok)check is dead code—resilientFetchalready throws for non-OK responses, so this block never executes.♻️ Remove the unreachable block
const response = await resilientFetch( `${this.baseUrls.registry}/api/services/register`, { method: "POST", headers: { "Content-Type": "application/json", Authorization: `Bearer ${this.env.CHITTY_REGISTRY_TOKEN}`, }, body: JSON.stringify(serviceConfig), }, ); - if (!response.ok) { - const error = await response.text(); - throw new Error( - `Service registration failed: ${response.status} - ${error}`, - ); - } - const result = await response.json();🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/integrations/chittyos-ecosystem.js` around lines 324 - 329, The if (!response.ok) block is unreachable dead code because the resilientFetch function already throws an error for non-OK responses before returning. Remove the entire if (!response.ok) conditional block that checks the response status and throws the error, as this logic is redundant and never executes.
🧹 Nitpick comments (2)
src/index.js (1)
2219-2223: 💤 Low valueConsider reducing
tracesSampleRatefor production.A
tracesSampleRateof1.0captures 100% of transactions, which can be costly at scale. Consider using0.1–0.2in production and reserving1.0for staging/debugging.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/index.js` around lines 2219 - 2223, The tracesSampleRate is hardcoded to 1.0 in the withSentry configuration, which captures 100% of transactions and can become costly in production environments. Make the tracesSampleRate value conditional based on the environment by checking the current environment (typically through env.NODE_ENV or similar), using a lower value like 0.1 or 0.2 for production environments and keeping 1.0 for staging or development environments. Update the configuration object returned in the withSentry wrapper to use this environment-aware tracesSampleRate value instead of the hardcoded 1.0.tests/utils/error-handling.test.js (1)
94-104: 💤 Low valueConsider asserting the full error message including response body.
The test validates that non-retryable errors throw immediately, but doesn't verify that the response body text is included in the error message—the key feature added in this PR. The mock at line 99 includes
text: async () => "Invalid input", but the assertion at line 102 only checks for"HTTP 400".♻️ Strengthen the test assertion
- await expect(resilientFetch("https://test-service.chitty.cc/api")).rejects.toThrow("HTTP 400"); + await expect(resilientFetch("https://test-service.chitty.cc/api")) + .rejects.toThrow(/HTTP 400: Bad Request - Invalid input/); expect(global.fetch).toHaveBeenCalledTimes(1); // Should not retry 400 errors🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/utils/error-handling.test.js` around lines 94 - 104, The test for resilientFetch in the "throws immediately on non-retryable errors" test case mocks a response body with "Invalid input" but the assertion on the await expect line only verifies that the error message contains "HTTP 400". Update the toThrow assertion to verify the complete error message including both the HTTP status and the response body text from the mocked text() method, ensuring that the error message properly includes the response body as intended by the PR feature.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/utils/error-handling.js`:
- Around line 330-335: The empty catch block in the try-catch statement around
the response.text() call violates the ESLint no-empty rule. Add a comment inside
the catch block (for example, "// Ignore errors reading response body") to
document the intentional no-op and satisfy the linter rule while preserving the
defensive behavior of silently ignoring errors when attempting to read the
response text.
In `@STATUS.md`:
- Around line 299-305: The STATUS.md file has inconsistent information where the
Phase 1 and Phase 2 sections mark rate limiting middleware and resilientFetch()
wrapping as complete (checked boxes), but the later sections such as "Known
Limitations" and "Security Status" still reference these features as missing or
not integrated. Update the "Known Limitations" and "Security Status" sections to
reflect that rate limiting and resilientFetch() wrapping are now complete and
integrated, ensuring the entire document presents a consistent view of the
current implementation status.
---
Outside diff comments:
In `@src/index.js`:
- Line 2472: The scheduled method parameter ctx is flagged by ESLint as unused.
To satisfy the linter convention for intentionally unused parameters, rename the
ctx parameter to _ctx in the scheduled method signature (where it appears
alongside event and env parameters).
- Around line 2161-2176: The function stripRedirectUriQueryParams is defined but
never called in the codebase, causing an ESLint unused function warning. Either
remove the entire stripRedirectUriQueryParams function if it is indeed dead
code, or rename it to _stripRedirectUriQueryParams by prefixing with an
underscore if it needs to be retained for future use or reference purposes.
In `@src/integrations/chittyos-ecosystem.js`:
- Around line 240-245: The if (!response.ok) block is unreachable code because
resilientFetch already throws an error for non-OK responses before returning, so
the response object will never have an ok property set to false. Remove the
entire if block that checks !response.ok and throws the error in the ChittyDNA
initialization section, as this error handling is already handled by the
resilientFetch function itself.
- Around line 401-406: The `if (!response.ok)` block is unreachable because
`resilientFetch` already throws an error for non-OK HTTP responses before
returning, so this error handling code never executes. Remove the entire `if
(!response.ok)` block including the response.text() call and the thrown Error,
keeping only the code that follows after this conditional block.
- Around line 362-367: The if (!response.ok) block starting after the
resilientFetch call is dead code that will never execute because resilientFetch
already throws an error for non-OK responses. Remove the entire conditional
block containing the response.ok check, the error text extraction, and the throw
statement. The remaining code after this block can proceed without this
redundant error handling.
- Around line 197-202: The `if (!response.ok)` block is unreachable dead code
because the `resilientFetch` function already throws an error for non-OK
responses, so execution never reaches this check. Remove the entire if statement
block (the condition check and the error throwing logic inside it) from the
ChittyID minting code, keeping only the code that executes after a successful
response.
- Around line 162-164: Remove the unreachable error handling block that checks
if (!response.ok). This block is dead code because the resilientFetch function
already throws an error when the response is not OK, so the code after the fetch
call will never execute if the response status is not OK. Delete the entire if
block that throws the error with the message about Registry discovery failed.
- Around line 279-284: The if (!response.ok) block that checks the response
status and throws an error is unreachable dead code because resilientFetch
already throws an exception for non-OK responses. Simply delete the entire if
block that checks !response.ok, along with the const error declaration and error
throwing logic. The code that follows this block will execute normally without
this redundant error handling.
- Around line 324-329: The if (!response.ok) block is unreachable dead code
because the resilientFetch function already throws an error for non-OK responses
before returning. Remove the entire if (!response.ok) conditional block that
checks the response status and throws the error, as this logic is redundant and
never executes.
---
Nitpick comments:
In `@src/index.js`:
- Around line 2219-2223: The tracesSampleRate is hardcoded to 1.0 in the
withSentry configuration, which captures 100% of transactions and can become
costly in production environments. Make the tracesSampleRate value conditional
based on the environment by checking the current environment (typically through
env.NODE_ENV or similar), using a lower value like 0.1 or 0.2 for production
environments and keeping 1.0 for staging or development environments. Update the
configuration object returned in the withSentry wrapper to use this
environment-aware tracesSampleRate value instead of the hardcoded 1.0.
In `@tests/utils/error-handling.test.js`:
- Around line 94-104: The test for resilientFetch in the "throws immediately on
non-retryable errors" test case mocks a response body with "Invalid input" but
the assertion on the await expect line only verifies that the error message
contains "HTTP 400". Update the toThrow assertion to verify the complete error
message including both the HTTP status and the response body text from the
mocked text() method, ensuring that the error message properly includes the
response body as intended by the PR feature.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 7404801b-938b-4340-b177-ad0efa0d108f
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (7)
STATUS.mdpackage.jsonscripts/safe-deploy.shsrc/index.jssrc/integrations/chittyos-ecosystem.jssrc/utils/error-handling.jstests/utils/error-handling.test.js
| let errorText = ""; | ||
| try { | ||
| errorText = await response.text(); | ||
| } catch (e) {} | ||
| const error = new Error( | ||
| `HTTP ${response.status}: ${response.statusText}`, | ||
| `HTTP ${response.status}: ${response.statusText}${errorText ? ' - ' + errorText : ''}`, |
There was a problem hiding this comment.
Fix the empty catch block to resolve pipeline failures.
The empty catch block at line 333 violates the ESLint no-empty rule and is causing all lint pipeline checks to fail. The defensive intent (silently ignoring errors when reading the response body) is correct, but the implementation needs adjustment.
🔧 Recommended fix options
Option 1 (preferred): Add a comment to document the intentional no-op
let errorText = "";
try {
errorText = await response.text();
- } catch (e) {}
+ } catch (e) {
+ // Ignore - error body is optional
+ }Option 2: Use a named parameter with underscore prefix
- } catch (e) {}
+ } catch (_e) {
+ // Body read failed, continue with status-only error
+ }Option 3: Inline disable (least preferred)
try {
errorText = await response.text();
+ // eslint-disable-next-line no-empty
} catch (e) {}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| let errorText = ""; | |
| try { | |
| errorText = await response.text(); | |
| } catch (e) {} | |
| const error = new Error( | |
| `HTTP ${response.status}: ${response.statusText}`, | |
| `HTTP ${response.status}: ${response.statusText}${errorText ? ' - ' + errorText : ''}`, | |
| let errorText = ""; | |
| try { | |
| errorText = await response.text(); | |
| } catch (e) { | |
| // Ignore - error body is optional | |
| } | |
| const error = new Error( | |
| `HTTP ${response.status}: ${response.statusText}${errorText ? ' - ' + errorText : ''}`, |
🧰 Tools
🪛 ESLint
[error] 333-333: Empty block statement.
(no-empty)
🪛 GitHub Actions: ChittyConnect CI / 2_Lint (20).txt
[error] 333-333: ESLint: Empty block statement (no-empty)
🪛 GitHub Actions: ChittyConnect CI / 3_Lint (22).txt
[error] 333-333: ESLint (no-empty): Empty block statement. Command: npm run lint --if-present
🪛 GitHub Actions: ChittyConnect CI / Lint (20)
[error] 333-333: ESLint (no-empty): Empty block statement
🪛 GitHub Actions: ChittyConnect CI / Lint (22)
[error] 333-333: ESLint: Empty block statement. (no-empty)
🪛 GitHub Check: Lint (20)
[failure] 333-333:
Empty block statement
🪛 GitHub Check: Lint (22)
[failure] 333-333:
Empty block statement
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/utils/error-handling.js` around lines 330 - 335, The empty catch block in
the try-catch statement around the response.text() call violates the ESLint
no-empty rule. Add a comment inside the catch block (for example, "// Ignore
errors reading response body") to document the intentional no-op and satisfy the
linter rule while preserving the defensive behavior of silently ignoring errors
when attempting to read the response text.
Sources: Linters/SAST tools, Pipeline failures
| - [x] Integrate rate limiting middleware in index.js | ||
| - [x] Add Sentry or Axiom monitoring | ||
| - [ ] Deploy CI/CD workflow (via web UI) | ||
| - [ ] Set up GitHub secrets (CLOUDFLARE_API_TOKEN, CLOUDFLARE_ACCOUNT_ID) | ||
|
|
||
| ### Phase 2: Important Improvements (3-5 days) | ||
| - [ ] Wrap service calls with resilientFetch() | ||
| - [x] Wrap service calls with resilientFetch() |
There was a problem hiding this comment.
Keep the status report internally consistent.
These checkboxes now say rate limiting and resilientFetch() wrapping are complete, but the later "Known Limitations" and "Security Status" sections still say both are missing/not integrated. Please update those sections too, or label this as historical status; otherwise the report is misleading.
🧰 Tools
🪛 LanguageTool
[uncategorized] ~299-~299: If this is a compound adjective that modifies the following noun, use a hyphen.
Context: ...itical Fixes (1-2 days) - [x] Integrate rate limiting middleware in index.js - [x] Add Sentry...
(EN_COMPOUND_ADJECTIVE_INTERNAL)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@STATUS.md` around lines 299 - 305, The STATUS.md file has inconsistent
information where the Phase 1 and Phase 2 sections mark rate limiting middleware
and resilientFetch() wrapping as complete (checked boxes), but the later
sections such as "Known Limitations" and "Security Status" still reference these
features as missing or not integrated. Update the "Known Limitations" and
"Security Status" sections to reflect that rate limiting and resilientFetch()
wrapping are now complete and integrated, ensuring the entire document presents
a consistent view of the current implementation status.
Summary
scripts/safe-deploy.shwas calling the legacy CF API endpointworkers/services/chittyconnect/environments/staging/bindings. In wrangler v4's per-env-worker model,--env stagingdeploys a standalone script namedchittyconnect-staging— theservices/chittyconnectservice object does not exist, so the API returns error 10092 and the script exits 71 even though the deploy itself succeeded.workers/scripts/{DEPLOYED_NAME}/bindings, whereDEPLOYED_NAMEis already computed correctly by the script (chittyconnect-stagingfor staging,chittyconnectfor production).GET /accounts/0bc21e3a5a9de1a4cc843be9c3e98121/workers/scripts/chittyconnect-staging/bindingsreturns HTTP 200, 74 bindings,result[].nameshape — the existingjq -r '.result[].name // empty'extraction is correct and unchanged.Before / After
Validation evidence
Probed live against
chittyconnect-stagingbefore committing:success: true, 74 bindings returnedservices/chittyconnect/environments/staging): CF error 10092 "This environment does not exist on this Worker"The fail-loud binding-drift logic (exit 72 on missing declared bindings) is fully preserved. Only the lookup target changes.
Impact
Unblocks the
Workers Builds: chittyconnectCI check on every chittyconnect PR, including #252 and #253, where the deploy succeeded but the audit always exited 71.Test plan
safe-deploy.sh stagingshould complete with[safe-deploy] OK — N declared bindings all presentscripts/chittyconnect/bindingsfor production where DEPLOYED_NAME == WORKER_NAME)🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Improvements
Tests