Adds get flows by product#65
Conversation
- Implement `WriteJSONResponse` utility to encode data to JSON and write HTTP responses with improved reliability. - Add unit tests to cover success, error, and content-type validation scenarios.
…Product` with tests
… for cleaner response handling
- Define HTTP GET request to fetch flows for a specific product using its ID. - Include request structure, example response, and response validation.
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (10)
📝 WalkthroughWalkthroughAdds GET /api/products/{id}/flows: introduces WriteJSONResponse and NotFoundError, refactors handlers to use the helper, adds a flow service abstraction, updates SQL/gen code and the Querier, wires the router, and adds handler/service tests plus Bruno documentation. ChangesGet Flows by Product Endpoint Implementation
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested labels
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 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 |
|
@CodeRabbit review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 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 `@_bruno/Flows/Get` Flows by Product.yml:
- Around line 53-58: The example response for the "Get Flows by Product" flow is
missing the product_id field; update the sample JSON object (the Flow example
with keys id, name, description, created_at, updated_at) to include the
product_id property with an appropriate sample value so the documented response
shape matches the endpoint contract.
In `@internal/flow/handler_test.go`:
- Around line 315-323: The test case named "No Flows Found" in
internal/flow/handler_test.go is asserting a 404 but the handler should return
200 with an empty array when the product exists but has no flows; update that
case so mockFlowQuerier.getFlowsByProductFunc returns (nil, nil) and
expectedStatus is http.StatusOK and assert an empty JSON array response. Also
add a new case (e.g., "Product Not Found") where
mockFlowQuerier.getFlowsByProductFunc returns (nil, pgx.ErrNoRows) and
expectedStatus is http.StatusNotFound to cover the missing-product contract.
In `@internal/flow/handler.go`:
- Around line 88-90: The handler currently treats pgx.ErrNoRows as "product not
found" and returns 404; instead distinguish the two cases by changing the data
layer/query and the handler: have the data function (e.g., GetFlowsByProduct)
return an explicit sentinel error ErrProductNotFound when the product row itself
is missing, and return an empty slice (and nil error) when the product exists
but has zero flows; then update the handler to check for errors.Is(err,
ErrProductNotFound) to call internal.HandleHttpError(..., http.StatusNotFound)
and otherwise treat a nil error with an empty slice as a 200 + [] response,
removing the current errors.Is(err, pgx.ErrNoRows) 404 branch.
🪄 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: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 3e0b6e2a-e50a-43cb-8bd5-6784ddb77e7c
📒 Files selected for processing (9)
_bruno/Flows/Get Flows by Product.ymlinternal/flow/handler.gointernal/flow/handler_test.gointernal/flow/interface.gointernal/platform/handler.gointernal/product/handler.gointernal/response.gointernal/response_test.gorouter/router.go
| "id": 1, | ||
| "name": "Flow 1", | ||
| "description": "flow 1 desc", | ||
| "created_at": "2026-05-15T19:11:09.35732-05:00", | ||
| "updated_at": "2026-05-15T19:11:09.35732-05:00" | ||
| } |
There was a problem hiding this comment.
Include product_id in the example response payload.
The sample response omits product_id, but the endpoint contract includes it. Please add it to keep docs aligned with actual response shape.
Suggested doc patch
[
{
"id": 1,
+ "product_id": 2,
"name": "Flow 1",
"description": "flow 1 desc",
"created_at": "2026-05-15T19:11:09.35732-05:00",
"updated_at": "2026-05-15T19:11:09.35732-05:00"
}
]📝 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.
| "id": 1, | |
| "name": "Flow 1", | |
| "description": "flow 1 desc", | |
| "created_at": "2026-05-15T19:11:09.35732-05:00", | |
| "updated_at": "2026-05-15T19:11:09.35732-05:00" | |
| } | |
| "id": 1, | |
| "product_id": 2, | |
| "name": "Flow 1", | |
| "description": "flow 1 desc", | |
| "created_at": "2026-05-15T19:11:09.35732-05:00", | |
| "updated_at": "2026-05-15T19:11:09.35732-05:00" | |
| } |
🤖 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 `@_bruno/Flows/Get` Flows by Product.yml around lines 53 - 58, The example
response for the "Get Flows by Product" flow is missing the product_id field;
update the sample JSON object (the Flow example with keys id, name, description,
created_at, updated_at) to include the product_id property with an appropriate
sample value so the documented response shape matches the endpoint contract.
| name: "No Flows Found", | ||
| pathID: "2", | ||
| mockSetup: func(m *mockFlowQuerier) { | ||
| m.getFlowsByProductFunc = func(ctx context.Context, productID int) ([]GetFlowsByProductRow, error) { | ||
| return nil, pgx.ErrNoRows | ||
| } | ||
| }, | ||
| expectedStatus: http.StatusNotFound, | ||
| }, |
There was a problem hiding this comment.
Update test expectations for empty-flow behavior and add the missing contract case.
The "No Flows Found" case expects 404, which conflicts with the endpoint requirement to return 200 with an empty array when the product exists but has no flows. Please add/adjust cases to explicitly cover:
- existing product + zero flows =>
200and[], and - missing product =>
404.
As per coding guidelines, **/*_test.go: "Assess the unit test code assessing sufficient code coverage for the changes associated in the pull request".
🤖 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 `@internal/flow/handler_test.go` around lines 315 - 323, The test case named
"No Flows Found" in internal/flow/handler_test.go is asserting a 404 but the
handler should return 200 with an empty array when the product exists but has no
flows; update that case so mockFlowQuerier.getFlowsByProductFunc returns (nil,
nil) and expectedStatus is http.StatusOK and assert an empty JSON array
response. Also add a new case (e.g., "Product Not Found") where
mockFlowQuerier.getFlowsByProductFunc returns (nil, pgx.ErrNoRows) and
expectedStatus is http.StatusNotFound to cover the missing-product contract.
…andling - Introduce `service` struct in `flow` package for business logic: `CreateFlow`, `GetFlowById`, and `GetFlowsByProduct`. - Update handlers to delegate flow operations to `service` and improve separation of concerns. - Add `NotFoundError` for standardized error handling in case of missing flows or products. - Update SQLC query for `GetFlowsByProduct` to include `product_id` in the result. - Add `GetProductById` query to validate product existence before fetching related flows.
- Added tests for `CreateFlow`, `GetFlowById`, and `GetFlowsByProduct` methods in the `service` layer. - Updated `CreateFlow` and `GetFlowById` handlers to handle `NotFoundError` and validation errors consistently. - Enhanced mock implementation to accommodate new service methods and error scenarios.
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (2)
internal/flow/handler_test.go (1)
304-311: ⚡ Quick winAssert
product_idin the success payload.The success case only checks
len(flows), so it would still pass ifproduct_iddisappeared from the response. That field is part of the endpoint contract and one of the key query changes in this PR.Suggested test tightening
m.getFlowsByProductFunc = func(ctx context.Context, productID int) ([]Flow, error) { if productID != 1 { return nil, errors.New("unexpected product id") } return []Flow{ - {ID: 1, Name: "Flow 1"}, - {ID: 2, Name: "Flow 2"}, + {ID: 1, ProductID: 1, Name: "Flow 1"}, + {ID: 2, ProductID: 1, Name: "Flow 2"}, }, nil } @@ if tt.expectedStatus == http.StatusOK { var flows []Flow if err := json.NewDecoder(rr.Body).Decode(&flows); err != nil { t.Fatalf("failed to decode response: %v", err) } if len(flows) != 2 { t.Errorf("expected 2 flows, got %v", len(flows)) } + for _, flow := range flows { + if flow.ProductID != 1 { + t.Errorf("expected ProductID 1, got %v", flow.ProductID) + } + } if rr.Header().Get("Content-Type") != "application/json" { t.Errorf("expected Content-Type application/json, got %v", rr.Header().Get("Content-Type")) } }As per coding guidelines,
**/*_test.go: "Assess the unit test code assessing sufficient code coverage for the changes associated in the pull request".Also applies to: 365-372
🤖 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 `@internal/flow/handler_test.go` around lines 304 - 311, The test's success assertions only check len(flows) and omit verifying the response includes the product_id; update the tests that use m.getFlowsByProductFunc (the success cases around the existing blocks returning []Flow) to decode the handler response JSON and assert that the top-level "product_id" equals the requested product (e.g., 1). Locate the test cases referencing m.getFlowsByProductFunc and Flow, parse the response body into the expected response struct or map, and add an assertion for product_id in both success scenarios (the blocks around the current getFlowsByProductFunc stubs, including the other case around lines 365-372).internal/flow/service_test.go (1)
92-150: ⚡ Quick winAdd test cases for untested service branches introduced in this PR.
Current tests miss: (1) generic DB error in
GetFlowById, (2) generic DB error fromGetProductById, (3) generic DB error fromGetFlowsByProduct, and (4) product exists with no flows (expect empty slice contract).As per coding guidelines, "Assess the unit test code assessing sufficient code coverage for the changes associated in the pull request".
Also applies to: 152-213
🤖 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 `@internal/flow/service_test.go` around lines 92 - 150, The tests for the service are missing coverage for several error and edge branches: add unit tests that use the mockFlowQuerier to simulate (1) a generic DB error returned from GetFlowById (not pgx.ErrNoRows) and assert the propagated error, (2) a generic DB error from GetProductById and assert propagation when calling the service method that depends on product lookup, (3) a generic DB error from GetFlowsByProduct and assert the service surfaces that error, and (4) a case where a product exists but GetFlowsByProduct returns an empty slice — assert the service returns an empty slice (not nil) to preserve the contract; implement these by adding table-driven test cases similar to TestService_GetFlowById that set mockFlowQuerier.getFlowFunc/getProductFunc/getFlowsByProductFunc to return the desired errors or empty slice and verify expected error messages or empty slice results.
🤖 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 `@internal/flow/service.go`:
- Around line 47-51: The GetFlowsByProduct return can propagate a nil []Flow
which JSON-encodes to null; after calling s.queries.GetFlowsByProduct(ctx, id)
and before returning, ensure the returned flows slice is normalized to an empty
slice when nil (e.g., if flows == nil then set flows = make([]Flow, 0)) so the
method (in service.go) always returns an empty array instead of null while
preserving the existing error handling around s.queries.GetFlowsByProduct.
- Around line 20-23: The current error branch checks errors.Is(err,
pgx.ErrNoRows) but INSERT ... RETURNING foreign-key failures surface as
*pgconn.PgError with SQLSTATE "23503", so replace the pgx.ErrNoRows check with
logic that type-asserts err to *pgconn.PgError and, when pgErr.Code == "23503"
(optionally also checking pgErr.Constraint or Detail for the product FK name),
return Flow{}, internal.NewNotFoundError(id, "Product"); otherwise fall back to
the existing fmt.Errorf("failed to create flow: %w", err) handling. Ensure you
import github.com/jackc/pgconn if not already.
In `@internal/response_test.go`:
- Around line 76-79: The test branch for encoding failures currently only checks
status and Content-Type; update the case where tt.expectedStatus ==
http.StatusInternalServerError to also decode the response body (w.Body.Bytes())
as JSON and assert the problem+json payload contains a "detail" field with the
expected error message (or at least that it contains text indicating an encoding
failure) so the contract produced by HandleHttpError is validated; use the same
test table entry's expected message or a concrete substring and reference w,
tt.expectedStatus, and HandleHttpError/response writer usage to locate where to
add the JSON decode and assertion.
---
Nitpick comments:
In `@internal/flow/handler_test.go`:
- Around line 304-311: The test's success assertions only check len(flows) and
omit verifying the response includes the product_id; update the tests that use
m.getFlowsByProductFunc (the success cases around the existing blocks returning
[]Flow) to decode the handler response JSON and assert that the top-level
"product_id" equals the requested product (e.g., 1). Locate the test cases
referencing m.getFlowsByProductFunc and Flow, parse the response body into the
expected response struct or map, and add an assertion for product_id in both
success scenarios (the blocks around the current getFlowsByProductFunc stubs,
including the other case around lines 365-372).
In `@internal/flow/service_test.go`:
- Around line 92-150: The tests for the service are missing coverage for several
error and edge branches: add unit tests that use the mockFlowQuerier to simulate
(1) a generic DB error returned from GetFlowById (not pgx.ErrNoRows) and assert
the propagated error, (2) a generic DB error from GetProductById and assert
propagation when calling the service method that depends on product lookup, (3)
a generic DB error from GetFlowsByProduct and assert the service surfaces that
error, and (4) a case where a product exists but GetFlowsByProduct returns an
empty slice — assert the service returns an empty slice (not nil) to preserve
the contract; implement these by adding table-driven test cases similar to
TestService_GetFlowById that set
mockFlowQuerier.getFlowFunc/getProductFunc/getFlowsByProductFunc to return the
desired errors or empty slice and verify expected error messages or empty slice
results.
🪄 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: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 499f24c7-e7b6-48e8-af0b-6e0375822ff4
📒 Files selected for processing (9)
internal/flow/flows.sqlinternal/flow/flows.sql.gen.gointernal/flow/handler.gointernal/flow/handler_test.gointernal/flow/querier.gen.gointernal/flow/service.gointernal/flow/service_test.gointernal/response.gointernal/response_test.go
| if errors.Is(err, pgx.ErrNoRows) { | ||
| return Flow{}, internal.NewNotFoundError(id, "Product") | ||
| } | ||
| return Flow{}, fmt.Errorf("failed to create flow: %w", err) |
There was a problem hiding this comment.
🧩 Analysis chain
🌐 Web query:
In pgx v5 with PostgreSQL, for INSERT ... RETURNINGthat violates a foreign key, is the errorpgx.ErrNoRowsor*pgconn.PgError (SQLSTATE 23503)?
💡 Result:
In pgx v5, an INSERT... RETURNING statement that violates a foreign key constraint will return a *pgconn.PgError (with SQLSTATE 23503), not pgx.ErrNoRows [1][2]. pgx.ErrNoRows is a specific error returned only when a query that is expected to return at least one row (such as QueryRow) finds no rows in the result set [3][4]. A foreign key violation is a database-level constraint error that occurs during the execution of the statement itself, which pgx surfaces as a *pgconn.PgError [2]. To handle this, you should use errors.As to check for the *pgconn.PgError type and inspect the Code field [2]: var pgErr *pgconn.PgError if errors.As(err, &pgErr) { if pgErr.Code == "23503" { // Handle foreign key violation } }
Citations:
- 1: https://www.bytebase.com/reference/postgres/error/23503-foreign-key-violation/
- 2: https://stackoverflow.com/questions/70515729/how-to-handle-postgres-query-error-with-pgx-driver-in-golang
- 3: Query or QueryRows does not return ErrNoRows error when no record is found jackc/pgx#2251
- 4: https://github.com/jackc/pgx/blob/master/rows.go
🏁 Script executed:
find . -name "service.go" -type f | grep -E "flow|service" | head -20Repository: service-atlas/products
Length of output: 93
🏁 Script executed:
cat -n ./internal/flow/service.go | head -35Repository: service-atlas/products
Length of output: 1109
Handle missing-product DB errors using FK violation mapping, not pgx.ErrNoRows.
Line 20 currently checks pgx.ErrNoRows, but for INSERT ... RETURNING with a missing referenced product, PostgreSQL returns a foreign key violation error (SQLSTATE 23503), which pgx surfaces as *pgconn.PgError, not pgx.ErrNoRows. This causes the error to incorrectly fall through to the generic error handler, returning a 500 instead of a 404 not-found response.
Proposed fix
import (
"context"
"errors"
"fmt"
"products/internal"
+ "github.com/jackc/pgx/v5/pgconn"
"github.com/jackc/pgx/v5"
)
@@
flow, err := s.queries.CreateFlow(ctx, req.ToParams(id))
if err != nil {
- if errors.Is(err, pgx.ErrNoRows) {
+ var pgErr *pgconn.PgError
+ if errors.As(err, &pgErr) && pgErr.Code == "23503" {
return Flow{}, internal.NewNotFoundError(id, "Product")
}
return Flow{}, fmt.Errorf("failed to create flow: %w", err)
}📝 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.
| if errors.Is(err, pgx.ErrNoRows) { | |
| return Flow{}, internal.NewNotFoundError(id, "Product") | |
| } | |
| return Flow{}, fmt.Errorf("failed to create flow: %w", err) | |
| var pgErr *pgconn.PgError | |
| if errors.As(err, &pgErr) && pgErr.Code == "23503" { | |
| return Flow{}, internal.NewNotFoundError(id, "Product") | |
| } | |
| return Flow{}, fmt.Errorf("failed to create flow: %w", err) |
🤖 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 `@internal/flow/service.go` around lines 20 - 23, The current error branch
checks errors.Is(err, pgx.ErrNoRows) but INSERT ... RETURNING foreign-key
failures surface as *pgconn.PgError with SQLSTATE "23503", so replace the
pgx.ErrNoRows check with logic that type-asserts err to *pgconn.PgError and,
when pgErr.Code == "23503" (optionally also checking pgErr.Constraint or Detail
for the product FK name), return Flow{}, internal.NewNotFoundError(id,
"Product"); otherwise fall back to the existing fmt.Errorf("failed to create
flow: %w", err) handling. Ensure you import github.com/jackc/pgconn if not
already.
| flows, err := s.queries.GetFlowsByProduct(ctx, id) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("failed to fetch flows: %w", err) | ||
| } | ||
| return flows, nil |
There was a problem hiding this comment.
Normalize no-result flow lists to an empty slice.
Line 51 can return a nil []Flow when a product exists but has no flows; JSON encoding then becomes null, while the endpoint contract requires an empty array.
Proposed fix
flows, err := s.queries.GetFlowsByProduct(ctx, id)
if err != nil {
return nil, fmt.Errorf("failed to fetch flows: %w", err)
}
+ if flows == nil {
+ return []Flow{}, nil
+ }
return flows, nil
}📝 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.
| flows, err := s.queries.GetFlowsByProduct(ctx, id) | |
| if err != nil { | |
| return nil, fmt.Errorf("failed to fetch flows: %w", err) | |
| } | |
| return flows, nil | |
| flows, err := s.queries.GetFlowsByProduct(ctx, id) | |
| if err != nil { | |
| return nil, fmt.Errorf("failed to fetch flows: %w", err) | |
| } | |
| if flows == nil { | |
| return []Flow{}, nil | |
| } | |
| return flows, nil |
🤖 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 `@internal/flow/service.go` around lines 47 - 51, The GetFlowsByProduct return
can propagate a nil []Flow which JSON-encodes to null; after calling
s.queries.GetFlowsByProduct(ctx, id) and before returning, ensure the returned
flows slice is normalized to an empty slice when nil (e.g., if flows == nil then
set flows = make([]Flow, 0)) so the method (in service.go) always returns an
empty array instead of null while preserving the existing error handling around
s.queries.GetFlowsByProduct.
| } else if tt.expectedStatus == http.StatusInternalServerError { | ||
| if w.Header().Get("Content-Type") != "application/problem+json" { | ||
| t.Errorf("expected Content-Type application/problem+json, got %s", w.Header().Get("Content-Type")) | ||
| } |
There was a problem hiding this comment.
Assert the error payload in the encoding-failure case.
The test only verifies status and Content-Type for encoding errors; it should also assert the error body contract (detail) so regressions in HandleHttpError payload shape/message are caught.
Suggested test assertion
} else if tt.expectedStatus == http.StatusInternalServerError {
if w.Header().Get("Content-Type") != "application/problem+json" {
t.Errorf("expected Content-Type application/problem+json, got %s", w.Header().Get("Content-Type"))
}
+ var got map[string]any
+ if err := json.Unmarshal(w.Body.Bytes(), &got); err != nil {
+ t.Fatalf("failed to unmarshal error body: %v", err)
+ }
+ if got["detail"] != "Failed to encode response" {
+ t.Errorf("expected detail %q, got %v", "Failed to encode response", got["detail"])
+ }
}As per coding guidelines, "/*_test.go: Assess the unit test code assessing sufficient code coverage for the changes associated in the pull request".
📝 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.
| } else if tt.expectedStatus == http.StatusInternalServerError { | |
| if w.Header().Get("Content-Type") != "application/problem+json" { | |
| t.Errorf("expected Content-Type application/problem+json, got %s", w.Header().Get("Content-Type")) | |
| } | |
| } else if tt.expectedStatus == http.StatusInternalServerError { | |
| if w.Header().Get("Content-Type") != "application/problem+json" { | |
| t.Errorf("expected Content-Type application/problem+json, got %s", w.Header().Get("Content-Type")) | |
| } | |
| var got map[string]any | |
| if err := json.Unmarshal(w.Body.Bytes(), &got); err != nil { | |
| t.Fatalf("failed to unmarshal error body: %v", err) | |
| } | |
| if got["detail"] != "Failed to encode response" { | |
| t.Errorf("expected detail %q, got %v", "Failed to encode response", got["detail"]) | |
| } | |
| } |
🤖 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 `@internal/response_test.go` around lines 76 - 79, The test branch for encoding
failures currently only checks status and Content-Type; update the case where
tt.expectedStatus == http.StatusInternalServerError to also decode the response
body (w.Body.Bytes()) as JSON and assert the problem+json payload contains a
"detail" field with the expected error message (or at least that it contains
text indicating an encoding failure) so the contract produced by HandleHttpError
is validated; use the same test table entry's expected message or a concrete
substring and reference w, tt.expectedStatus, and HandleHttpError/response
writer usage to locate where to add the JSON decode and assertion.
- Move generated SQLC files from `internal/flow` to `internal/flow/db` for better organization. - Update imports and type references in the `flow` service, handlers, and tests to use `db` package. - Adjust mock implementations and test cases to match new package structure.
- Change SQLC output path from `internal/flow` to `internal/flow/db` for better organization and alignment with package structure.
Description
Code Rabbit Summary
Summary by CodeRabbit
New Features
Improvements
Tests
Fixes
Closes #36
Post Deployment Tasks?