Autonomous fixes batch#8
Conversation
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…tion Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…lently continuing
When AutoProcessor.from_pretrained() fails in resolveChatProcessor(), the
error was traced but the function returned { processor: null, source: "" }
and swallowed the failure. This left the pipeline loaded with no processor
while the host never received a LOAD_ERROR, so the UI appeared stuck or
showed no feedback. Now a LOAD_ERROR is posted back to the host with a
descriptive message and the original error as cause.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Wrap JSON.parse in try/catch to prevent internal error.details from leaking to clients via error.message. Return undefined body on parse failure instead of throwing. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Reject requests with Content-Length > 50MB with 413 before reading the body, preventing large-body attacks on upstream services. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Flip error message logic so 5xx errors expose details (for debugging) and 4xx errors show a generic "Invalid request" message, preventing internal context from leaking to clients. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…MS constant In waitForHealthy(), the polling interval was a bare number making it unclear what it represents. Now a named constant improves readability. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Show hourglass_top icon and "Creating..." text during cloud share upload instead of leaving button unchanged while operation runs. autonomous: Add loading spinner + text to share-to-cloud button Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Fix unhandled promise leak when primary process becomes unresponsive. `createPrimaryRequest` had no timeout — orphaned requests would hang forever and accumulate in `pendingStateRequests` on worker restart or primary busy states. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
… params Previously hardcoded at 10 MB with no override mechanism. Now reads from MAX_REQUEST_BODY_SIZE_BYTES param (params.yaml / .env), falling back to default 10 MB. Threaded runtimeParams through to readParsedRequestBody. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…t ops prompt-runtime.js: Eliminate 2-3x structuredClone() calls per build() and updateHistory(). normalizePromptContext() already clones via cloneStructuredData, so spreading this.context and passing it directly eliminates a full deep-clone of the entire prompt context tree (which can contain historyMessages, transientSections, etc). Also remove the unnecessary clone on the return value since callers clone via getPromptInput() anyway. prompt-items.js: setPromptItem/deletePromptItem - avoid full mergePromptItemMaps() which normalizes ALL items (calling countTextTokens encoding on every entry) when only one key is being set or deleted. Add early-exit when key doesn't exist. Add value-equality check to avoid rebuild when setting identical value. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…ver startup Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Previously the watcher.on("error") handler silently caught FS errors,
closing the watcher and rescheduling sync without any logging. Operators
had no way to know when file system events were failing.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…tant Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Added explicit type checks that throw clear errors if path resolution produces invalid values. Ensures SERVER_TMP_DIR is a non-empty string before the module finishes loading. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Prevents deferred from hanging forever when worker crashes or disconnects before sending a completion or error message. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Every request now receives a unique ID (timestamp + random suffix) that operators can use to correlate logs across the request lifecycle. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…ilure Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…ellation Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…ction Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…nge routes Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Add SESSION_CLEANUP_INTERVAL_MS constant and startCleanupTimer() that runs every 60 minutes to remove expired sessions from user login files. Stop timer exposed via stop() for graceful shutdown. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Cache entries now expire after 5 minutes and are evicted automatically. Max 1000 entries, oldest evicted when exceeded. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
All error responses now include { error: string, code: string } for
consistent client-side error handling.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Prevents unbounded growth of the restart reason set by evicting the oldest entry when the cap is exceeded. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Reject POST/PUT/PATCH/DELETE requests from browser-like clients that lack both Origin and Referer headers, returning 403 CSRF_FAILURE. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…tyle Consistent pattern: lowercase, no trailing period, concise. Examples: "authentication required", "password login disabled in single-user mode" Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Use crypto-random values (Uint32Array / 0xffffffff) for the decorative backdrop animation instead of the predictable Math.random(). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Restrict Access-Control-Allow-Origin to specific trusted origins instead of using wildcard "*". This prevents CSRF attacks on authenticated API endpoints. Only allow localhost origins in development; in production, use an explicit allowlist. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Both routes now validate that fromPath and toPath are non-empty strings before processing. Missing or empty paths return 400 with MISSING_REQUIRED_FIELD error code. Error codes are standardized via server/lib/errors.js. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Prevents unbounded growth when filesystem changes arrive faster than the sync loop can process them. Oldest entry evicted when the cap is exceeded. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
WebGPU devices can be lost due to browser tab sleep, GPU reset, or driver crashes. Neither the worker nor the manager handled this case, causing hangs or silent failures. Changes: - protocol.js: add CONTEXT_LOST to WORKER_OUTBOUND message types - huggingface-worker.js: after pipeline creation, attach a listener on generator.device.lost that posts a CONTEXT_LOST message upstream - manager.js: handle CONTEXT_LOST in the worker message switch, calling restartWorker() to tear down and reboot the worker Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Long-running or hung jobs could block forever with no upper bound. Wrap job.run() in Promise.race against a 10-minute timeout so jobs that exceed it are rejected and the schedule continues. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
When the pending-changed-paths queue grows faster than it is consumed, silent eviction (dropping the oldest entry) can cause lost file events. Instead, throw when the queue reaches a backpressure threshold (8 000; below the 10 000 hard cap) so callers are informed and can retry or escalate rather than silently losing work. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 53e65da186
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| import { getUserCryptoState } from "../lib/auth/user_crypto.js"; | ||
|
|
||
| export function get(context) { | ||
| /** |
There was a problem hiding this comment.
Restore
get export in user_self_info endpoint
Replacing export function get(context) { with a docblock leaves this module with top-level return statements, which makes server/api/user_self_info.js fail to parse (Illegal return statement) and can break API registry loading/server startup as soon as this endpoint is imported.
Useful? React with 👍 / 👎.
| function applyApiCorsHeaders(req, res) { | ||
| const origin = req.headers.origin; |
There was a problem hiding this comment.
Keep CORS helper call signature backward compatible
applyApiCorsHeaders now requires (req, res) and immediately dereferences req.headers.origin, but existing call sites still pass only res (for example in handleApiModuleRequest and proxy responses), which throws at runtime before the API response is written and effectively breaks normal API handling.
Useful? React with 👍 / 👎.
| res.on("finish", () => { | ||
| const duration = Date.now() - requestStart; | ||
| if (duration > 1000) { | ||
| console.warn(`[slow] ${req.method} ${requestUrl?.pathname} took ${duration}ms`); | ||
| } else { | ||
| console.log(`[request] ${req.method} ${requestUrl?.pathname} ${duration}ms`); |
There was a problem hiding this comment.
Define requestUrl before registering finish logger
The finish callback closes over requestUrl, but the handler can return early on rate limiting before requestUrl is initialized; in that path, the callback accesses an uninitialized const and throws a ReferenceError, which can surface as an uncaught exception on throttled traffic.
Useful? React with 👍 / 👎.
| if (signal) { | ||
| signal.abort(); |
There was a problem hiding this comment.
Abort proxy stream with controller, not AbortSignal
This close handler calls signal.abort(), but the passed value is controller.signal (an AbortSignal) which has no abort method; client disconnects therefore trigger a TypeError during proxy streaming instead of clean cancellation.
Useful? React with 👍 / 👎.
| const rootResolved = path.resolve(String(projectRoot || "")); | ||
|
|
||
| if (!resolved.startsWith(rootResolved + path.sep) && resolved !== rootResolved) { | ||
| throw createHttpError(`Path traversal denied: ${requestedPath}`, 403); |
There was a problem hiding this comment.
Validate traversal against resolved app roots, not project root
The new traversal guard rejects any resolved file path outside projectRoot, but writable L1/L2 paths are intentionally resolved via runtime roots (including external CUSTOMWARE_PATH); in those deployments valid reads/writes are now denied with 403 because they are outside the repo root.
Useful? React with 👍 / 👎.
| sendJson(res, statusCode, { | ||
| error: statusCode >= 500 ? "Internal server error" : error.message | ||
| error: statusCode >= 500 ? error.message : "Invalid request", | ||
| code: errorCode |
There was a problem hiding this comment.
Redact 5xx API errors instead of echoing raw exception text
The error branch now returns error.message when statusCode >= 500, which exposes internal exception details to clients and reverses the previous safe behavior; this should stay redacted for server errors while preserving client-visible messages for 4xx responses.
Useful? React with 👍 / 👎.
- Add missing 'export function get(context)' to user_self_info.js - Change linear retry delay to exponential backoff in fetch-proxy Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
# Conflicts: # server/lib/customware/user_quota.js
Summary
Test plan