Non-GET requests to existing /_next/static - #142
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThe PR separates device status and organization count queries, updates dashboard consumers, and adds a Docker entrypoint that converts matching Next.js static-file responses from HTTP 500 to HTTP 405. ChangesDevice count query separation
HTTP static-file method handling
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant Dashboard
participant DeviceAPI
participant GraphQL
Dashboard->>DeviceAPI: request status and organization counts
DeviceAPI->>GraphQL: execute separate count queries
GraphQL-->>DeviceAPI: return count maps
DeviceAPI-->>Dashboard: return typed results
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
|
FE review note: the doc comment has one factual inaccuracy - the paragraph claiming direct navigation to Everything else checks out against Next 16.2.4 sources ( |
…cted Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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/app/`(app)/dashboard/hooks/use-customers-overview.ts:
- Around line 100-108: Preserve failures in fetchOrganizations and
fetchCustomersOverview instead of returning null or swallowing caught errors, so
failed requests are distinguishable from an empty customer state. Update the
owning overview hook to use useToast and show feedback for both successful
queries and errors, while retaining normal rendering for valid empty results.
In `@src/app/`(app)/devices/queries/devices-queries.ts:
- Around line 43-65: Replace the raw device-count and organization-list GraphQL
POST flows with narrow Relay operations: update
src/app/(app)/devices/queries/devices-queries.ts lines 43-65 to define
source-file-prefixed Relay queries, update
src/app/(app)/devices/queries/devices-api.ts lines 174-197 to use fetchQuery for
the imperative callers, and update
src/app/(app)/dashboard/hooks/use-customers-overview.ts lines 91-98 to use the
generated Relay operation; then run the Relay compiler.
🪄 Autofix
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: 8d6be053-ecec-457c-9011-67de3b96dc3f
📒 Files selected for processing (7)
Dockerfilescripts/server-entry.jssrc/app/(app)/customers/hooks/use-customer-device-counts.tssrc/app/(app)/dashboard/hooks/use-customers-overview.tssrc/app/(app)/dashboard/services/dashboard-api-service.tssrc/app/(app)/devices/queries/devices-api.tssrc/app/(app)/devices/queries/devices-queries.ts
| if (!orgsResponse.ok) { | ||
| console.warn('Organizations overview API failed:', orgsResponse.error || orgsResponse.status); | ||
| return null; | ||
| } | ||
|
|
||
| const orgsData = orgsResponse.data?.data?.organizations; | ||
| if (!orgsData) { | ||
| console.warn('Invalid organizations overview response structure'); | ||
| return null; |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
ast-grep outline 'src/app/(app)/dashboard/hooks/use-customers-overview.ts' --items all
rg -n -C 3 --type ts '\b(useToast|useQuery|fetchCustomersOverview)\b' \
'src/app/(app)/dashboard/hooks/use-customers-overview.ts'Repository: flamingo-stack/openframe-oss-frontend
Length of output: 2196
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '--- hook implementation ---'
sed -n '80,230p' 'src/app/(app)/dashboard/hooks/use-customers-overview.ts'
printf '%s\n' '--- hook consumers ---'
rg -n -C 5 --type tsx 'useCustomersOverview|totalOrganizations|organizationOverview' 'src/app/(app)/dashboard'
printf '%s\n' '--- toast patterns in nearby hooks ---'
rg -n -C 4 --type ts '\buseToast\b' 'src/app/(app)/dashboard' 'src/app/(app)/devices' | head -240Repository: flamingo-stack/openframe-oss-frontend
Length of output: 5019
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '--- dashboard consumers ---'
rg -n -C 6 'useCustomersOverview|totalOrganizations|rows\.length|No Customers added yet' 'src/app/(app)/dashboard' --glob '*.tsx' --glob '*.ts' || true
printf '%s\n' '--- toast API and nearby usage ---'
rg -n -C 5 '\buseToast\b' src --glob '*.tsx' --glob '*.ts' | head -300
printf '%s\n' '--- query error handling patterns ---'
rg -n -C 6 'query\.isError|query\.error|onError|onSuccess' 'src/app/(app)/dashboard' --glob '*.tsx' --glob '*.ts' | head -300Repository: flamingo-stack/openframe-oss-frontend
Length of output: 42976
Preserve organization fetch errors. Throw or expose an error when fetchOrganizations() returns null or fetchCustomersOverview() catches a failure. Otherwise, the consumer renders “No Customers added yet” for failed requests. Add useToast feedback for query success and errors in the owning hook.
🤖 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/app/`(app)/dashboard/hooks/use-customers-overview.ts around lines 100 -
108, Preserve failures in fetchOrganizations and fetchCustomersOverview instead
of returning null or swallowing caught errors, so failed requests are
distinguishable from an empty customer state. Update the owning overview hook to
use useToast and show feedback for both successful queries and errors, while
retaining normal rendering for valid empty results.
Source: Coding guidelines
| export const GET_DEVICE_STATUS_COUNTS_QUERY = ` | ||
| query GetDeviceStatusCounts($filter: DeviceFilterInput) { | ||
| deviceFilters(filter: $filter) { | ||
| statuses { | ||
| value | ||
| count | ||
| } | ||
| filteredCount | ||
| } | ||
| } | ||
| `; | ||
|
|
||
| /** Per-organization device counts — the customers table and the dashboard overview. */ | ||
| export const GET_DEVICE_ORGANIZATION_COUNTS_QUERY = ` | ||
| query GetDeviceOrganizationCounts($filter: DeviceFilterInput) { | ||
| deviceFilters(filter: $filter) { | ||
| organizationIds { | ||
| value | ||
| count | ||
| } | ||
| filteredCount | ||
| } | ||
| } | ||
| `; |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟠 Major | 🏗️ Heavy lift
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
rg -n -C 4 --type ts \
'\b(postDeviceQuery|apiClient\.post|fetchQuery|useLazyLoadQuery|loadQuery)\b|GET_DEVICE_(STATUS|ORGANIZATION)_COUNTS_QUERY' \
'src/app/(app)/devices/queries/devices-api.ts' \
'src/app/(app)/devices/queries/devices-queries.ts' \
'src/app/(app)/dashboard/hooks/use-customers-overview.ts'
rg -n -C 3 --type ts 'graphql`|graphql\s*`|fetchQuery<' 'src/app'Repository: flamingo-stack/openframe-oss-frontend
Length of output: 50393
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '--- focused diff ---'
git diff --unified=25 -- \
'src/app/(app)/devices/queries/devices-queries.ts' \
'src/app/(app)/devices/queries/devices-api.ts' \
'src/app/(app)/dashboard/hooks/use-customers-overview.ts'
printf '%s\n' '--- devices-api imports and count callers ---'
sed -n '1,230p' 'src/app/(app)/devices/queries/devices-api.ts'
rg -n -C 5 --type ts \
'fetchDeviceStatusCounts|fetchDeviceOrganizationCounts|fetchOrganizations|GET_ORGANIZATIONS_QUERY|deviceFiltersRelayQuery|organization.*Relay|organizations.*graphql' \
'src/app' 'src/graphql' 'src/__generated__'
printf '%s\n' '--- customers overview ---'
sed -n '1,180p' 'src/app/(app)/dashboard/hooks/use-customers-overview.ts'
printf '%s\n' '--- Relay configuration and scripts ---'
rg -n -C 3 \
'relay|compiler|codegen' \
package.json relay.config.* '*.config.*' 2>/dev/null || trueRepository: flamingo-stack/openframe-oss-frontend
Length of output: 36526
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '--- existing device Relay facet ---'
sed -n '1,180p' 'src/graphql/devices/device-filters-relay.ts'
printf '%s\n' '--- device query documents ---'
sed -n '1,120p' 'src/app/(app)/devices/queries/devices-queries.ts'
printf '%s\n' '--- organization Relay documents and generated types ---'
rg -l --type tsx --type ts 'organizations\s*\(' 'src/graphql' 'src/app' | sort
rg -n -C 8 --type tsx --type ts \
'query [A-Za-z0-9_]*Organization|organizations\s*\(|Organization.*Query' \
'src/graphql' 'src/app/(app)' | head -n 240
printf '%s\n' '--- cited endpoint/document structural check ---'
python3 - <<'PY'
from pathlib import Path
files = [
Path('src/app/(app)/devices/queries/devices-api.ts'),
Path('src/app/(app)/dashboard/hooks/use-customers-overview.ts'),
]
for path in files:
text = path.read_text()
print(path)
for needle in ("apiClient.post", "postDeviceQuery", "graphql`", "/api/graphql", "GET_DEVICE_STATUS_COUNTS_QUERY",
"GET_DEVICE_ORGANIZATION_COUNTS_QUERY", "GET_ORGANIZATIONS_QUERY"):
print(f" {needle}: {text.count(needle)}")
PYRepository: flamingo-stack/openframe-oss-frontend
Length of output: 4361
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '--- organization GraphQL documents ---'
rg -n -C 8 --glob '*.ts' --glob '*.tsx' \
'graphql`|query [A-Za-z0-9_]*Organization|organizations\s*\(' \
src/graphql 'src/app/(app)' | head -n 320
printf '%s\n' '--- generated organization query artifacts ---'
find src/__generated__ -maxdepth 1 -type f -iname '*organization*' -printf '%f\n' | sort | head -n 120
rg -n -C 3 --glob '*.ts' \
'Organizations|organizations|OrganizationConnection' src/__generated__ | head -n 240
printf '%s\n' '--- Relay configuration and repository state ---'
find . -maxdepth 2 -type f \( -iname '*relay*config*' -o -name 'relay.config.js' -o -name 'relay.config.json' \) -print
git status --shortRepository: flamingo-stack/openframe-oss-frontend
Length of output: 27577
Use Relay for the new /api/graphql operations.
Replace the raw device-count and organization-list POST calls with narrow, source-file-prefixed Relay operations. Use fetchQuery for these imperative callers and run the Relay compiler.
📍 Affects 3 files
src/app/(app)/devices/queries/devices-queries.ts#L43-L65(this comment)src/app/(app)/devices/queries/devices-api.ts#L174-L197src/app/(app)/dashboard/hooks/use-customers-overview.ts#L91-L98
🤖 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/app/`(app)/devices/queries/devices-queries.ts around lines 43 - 65,
Replace the raw device-count and organization-list GraphQL POST flows with
narrow Relay operations: update src/app/(app)/devices/queries/devices-queries.ts
lines 43-65 to define source-file-prefixed Relay queries, update
src/app/(app)/devices/queries/devices-api.ts lines 174-197 to use fetchQuery for
the imperative callers, and update
src/app/(app)/dashboard/hooks/use-customers-overview.ts lines 91-98 to use the
generated Relay operation; then run the Relay compiler.
Source: Coding guidelines
Summary by CodeRabbit
Bug Fixes
Performance