Add nutrient endpoint#131
Conversation
📝 WalkthroughWalkthroughAdds ChangesAI nutrient generation
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant Client
participant SpringAPI
participant RecipeService
participant LLM
Client->>SpringAPI: POST /ai/nutrients
SpringAPI->>RecipeService: Forward signed nutrient request
RecipeService->>LLM: Generate structured nutrients
LLM-->>RecipeService: RecipeNutrients
RecipeService-->>SpringAPI: RecipeNutrients
SpringAPI-->>Client: RecipeNutrients response
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ 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 |
|
🚀 Frontend preview ↗ · commit |
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (10)
services/spring-api/src/main/kotlin/org/openapitools/model/AuthResponse.kt (1)
25-27: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAvoid the empty generated class body.
Detekt reports
EmptyClassBlockfor this body. Remove the braces, update the generator template, or exclude generated sources from this rule to avoid lint warnings.🤖 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 `@services/spring-api/src/main/kotlin/org/openapitools/model/AuthResponse.kt` around lines 25 - 27, The generated AuthResponse class has an empty body triggering Detekt’s EmptyClassBlock warning. Update the generator template producing AuthResponse to omit the empty braces, or configure Detekt to exclude generated sources from this rule.Source: Linters/SAST tools
services/spring-api/src/main/kotlin/org/openapitools/model/AuthRequest.kt (1)
31-33: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAvoid the empty generated class body.
Detekt reports
EmptyClassBlockfor this body. Remove the braces, update the generator template, or exclude generated sources from this rule to avoid lint warnings.🤖 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 `@services/spring-api/src/main/kotlin/org/openapitools/model/AuthRequest.kt` around lines 31 - 33, Remove the empty class body from the generated AuthRequest declaration, or update the generator template that produces it so empty classes use no braces; alternatively configure Detekt to exclude generated sources from EmptyClassBlock checks.Source: Linters/SAST tools
services/spring-api/src/main/kotlin/org/openapitools/model/UserProfileUpdate.kt (1)
37-39: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAvoid the empty generated class body.
Detekt reports
EmptyClassBlockfor this body. Remove the braces, update the generator template, or exclude generated sources from this rule to avoid lint warnings.🤖 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 `@services/spring-api/src/main/kotlin/org/openapitools/model/UserProfileUpdate.kt` around lines 37 - 39, The generated UserProfileUpdate class has an empty body that triggers Detekt’s EmptyClassBlock rule. Remove the empty braces from UserProfileUpdate, preferably by correcting the generator template, or configure Detekt to exclude generated sources.Source: Linters/SAST tools
services/spring-api/src/main/kotlin/org/openapitools/model/ErrorResponse.kt (1)
25-27: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAvoid the empty generated class body.
Detekt reports
EmptyClassBlockfor this body. Remove the braces, update the generator template, or exclude generated sources from this rule to avoid lint warnings.🤖 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 `@services/spring-api/src/main/kotlin/org/openapitools/model/ErrorResponse.kt` around lines 25 - 27, Remove the empty class body in ErrorResponse by using a declaration without braces, and update the generator template that produces this model so future generated classes follow the same form; alternatively, configure Detekt to exclude generated sources from EmptyClassBlock.Source: Linters/SAST tools
services/spring-api/src/main/kotlin/org/openapitools/model/UserProfile.kt (1)
31-33: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAvoid the empty generated class body.
Detekt reports
EmptyClassBlockfor this body. Remove the braces, update the generator template, or exclude generated sources from this rule to avoid lint warnings.🤖 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 `@services/spring-api/src/main/kotlin/org/openapitools/model/UserProfile.kt` around lines 31 - 33, Remove the empty class body from UserProfile and update the source generator template producing it so generated models use the brace-free declaration; alternatively, configure Detekt to exclude generated sources from EmptyClassBlock.Source: Linters/SAST tools
services/spring-api/src/main/kotlin/org/openapitools/model/RecipeUpdate.kt (1)
48-50: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winRemove the empty class body or exclude generated models from detekt.
RecipeUpdatehas no body members, and detekt reportsempty-blocks.EmptyClassBlock. Apply the fix in the generator/template, or exclude generated sources from this rule.Proposed fix
-) { - -} +)🤖 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 `@services/spring-api/src/main/kotlin/org/openapitools/model/RecipeUpdate.kt` around lines 48 - 50, RecipeUpdate has an empty class body that triggers detekt’s EmptyClassBlock rule. Fix the model generator/template to omit the empty body for memberless generated classes, or configure detekt to exclude generated model sources from this rule.Source: Linters/SAST tools
services/spring-api/src/main/kotlin/org/openapitools/model/RecipeRequest.kt (1)
33-35: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winRemove the empty class body or exclude generated models from detekt.
RecipeRequesthas no body members, but the explicit{}triggers detekt’sempty-blocks.EmptyClassBlockwarning. Fix this in the generator/template or exclude generated sources.Proposed fix
-) { - -} +)🤖 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 `@services/spring-api/src/main/kotlin/org/openapitools/model/RecipeRequest.kt` around lines 33 - 35, Remove the empty class body from the generated RecipeRequest declaration, or update the generator/template responsible for RecipeRequest to omit {} for empty models; alternatively configure detekt to exclude generated model sources, including RecipeRequest.Source: Linters/SAST tools
services/spring-api/src/main/kotlin/org/openapitools/model/UserCredentials.kt (1)
31-33: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winRemove the empty class body or exclude generated models from detekt.
UserCredentialshas no body members, while detekt reportsempty-blocks.EmptyClassBlock. Fix the generator/template or exclude generated sources from this rule.Proposed fix
-) { - -} +)🤖 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 `@services/spring-api/src/main/kotlin/org/openapitools/model/UserCredentials.kt` around lines 31 - 33, Address the detekt EmptyClassBlock violation for UserCredentials by updating the model generator/template to omit the empty class body, or configure detekt to exclude generated model sources from this rule. Prefer the generator/template fix if these files are regenerated.Source: Linters/SAST tools
services/spring-api/src/main/kotlin/org/openapitools/model/RecipeNutrients.kt (1)
40-42: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winRemove the empty class body or exclude generated models from detekt.
RecipeNutrientshas no members in its body, and detekt reportsempty-blocks.EmptyClassBlock. Remove{}in the generator/template, or configure generated sources to be excluded from this rule.Proposed fix
-) { - -} +)🤖 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 `@services/spring-api/src/main/kotlin/org/openapitools/model/RecipeNutrients.kt` around lines 40 - 42, Resolve the detekt EmptyClassBlock violation for RecipeNutrients by removing its empty class body in the generator/template, or excluding generated model sources from this detekt rule; prefer the generator/template change so generated models no longer emit empty braces.Source: Linters/SAST tools
services/spring-api/src/main/kotlin/org/openapitools/model/HelpRequest.kt (1)
31-33: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winRemove the explicit empty class body from generated models.
Detekt flags this empty body. Remove it in the generator/template rather than retaining
{}across regenerated model classes.🤖 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 `@services/spring-api/src/main/kotlin/org/openapitools/model/HelpRequest.kt` around lines 31 - 33, Remove the explicit empty class body from the generator/template that produces HelpRequest and other generated model classes, ensuring generated declarations end without empty braces and remain Detekt-compliant after regeneration.Source: Linters/SAST tools
🤖 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 `@api/openapi.yaml`:
- Around line 756-766: Resolve the mismatch for NutrientRequest.language: either
remove the language property and its description from the OpenAPI
NutrientRequest schema, or propagate it through AIApiController into the Python
nutrient-generation request and incorporate it into the prompt construction in
main.py. Keep the schema, internal request model, controller forwarding, and
prompt behavior consistent.
In
`@services/py-help-service/client/cooking_assistant_gen_ai_services_api_internal_client/api/recipe_service/post_ai_nutrients.py`:
- Around line 72-80: The `_build_response` function converts every HTTP status
to `HTTPStatus`, which fails for non-standard codes before unexpected-status
handling runs. Preserve `response.status_code` as a raw integer in the
`Response` construction, or update `Response.status_code` to accept arbitrary
integers while maintaining the existing `raise_on_unexpected_status` and
`UnexpectedStatus` behavior.
In `@services/spring-api/src/main/kotlin/org/openapitools/api/AIApiController.kt`:
- Around line 101-121: Preserve NutrientRequest.language when forwarding
requests from aiNutrientsPost: add a corresponding language field to
NutrientRequestForwarded and populate it from nutrientRequest.language when
constructing the internal request. If language is intentionally unsupported,
remove it from the public NutrientRequest model instead.
---
Nitpick comments:
In `@services/spring-api/src/main/kotlin/org/openapitools/model/AuthRequest.kt`:
- Around line 31-33: Remove the empty class body from the generated AuthRequest
declaration, or update the generator template that produces it so empty classes
use no braces; alternatively configure Detekt to exclude generated sources from
EmptyClassBlock checks.
In `@services/spring-api/src/main/kotlin/org/openapitools/model/AuthResponse.kt`:
- Around line 25-27: The generated AuthResponse class has an empty body
triggering Detekt’s EmptyClassBlock warning. Update the generator template
producing AuthResponse to omit the empty braces, or configure Detekt to exclude
generated sources from this rule.
In `@services/spring-api/src/main/kotlin/org/openapitools/model/ErrorResponse.kt`:
- Around line 25-27: Remove the empty class body in ErrorResponse by using a
declaration without braces, and update the generator template that produces this
model so future generated classes follow the same form; alternatively, configure
Detekt to exclude generated sources from EmptyClassBlock.
In `@services/spring-api/src/main/kotlin/org/openapitools/model/HelpRequest.kt`:
- Around line 31-33: Remove the explicit empty class body from the
generator/template that produces HelpRequest and other generated model classes,
ensuring generated declarations end without empty braces and remain
Detekt-compliant after regeneration.
In
`@services/spring-api/src/main/kotlin/org/openapitools/model/RecipeNutrients.kt`:
- Around line 40-42: Resolve the detekt EmptyClassBlock violation for
RecipeNutrients by removing its empty class body in the generator/template, or
excluding generated model sources from this detekt rule; prefer the
generator/template change so generated models no longer emit empty braces.
In `@services/spring-api/src/main/kotlin/org/openapitools/model/RecipeRequest.kt`:
- Around line 33-35: Remove the empty class body from the generated
RecipeRequest declaration, or update the generator/template responsible for
RecipeRequest to omit {} for empty models; alternatively configure detekt to
exclude generated model sources, including RecipeRequest.
In `@services/spring-api/src/main/kotlin/org/openapitools/model/RecipeUpdate.kt`:
- Around line 48-50: RecipeUpdate has an empty class body that triggers detekt’s
EmptyClassBlock rule. Fix the model generator/template to omit the empty body
for memberless generated classes, or configure detekt to exclude generated model
sources from this rule.
In
`@services/spring-api/src/main/kotlin/org/openapitools/model/UserCredentials.kt`:
- Around line 31-33: Address the detekt EmptyClassBlock violation for
UserCredentials by updating the model generator/template to omit the empty class
body, or configure detekt to exclude generated model sources from this rule.
Prefer the generator/template fix if these files are regenerated.
In `@services/spring-api/src/main/kotlin/org/openapitools/model/UserProfile.kt`:
- Around line 31-33: Remove the empty class body from UserProfile and update the
source generator template producing it so generated models use the brace-free
declaration; alternatively, configure Detekt to exclude generated sources from
EmptyClassBlock.
In
`@services/spring-api/src/main/kotlin/org/openapitools/model/UserProfileUpdate.kt`:
- Around line 37-39: The generated UserProfileUpdate class has an empty body
that triggers Detekt’s EmptyClassBlock rule. Remove the empty braces from
UserProfileUpdate, preferably by correcting the generator template, or configure
Detekt to exclude generated sources.
🪄 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 Plus
Run ID: 57555deb-0395-4d5e-9181-b1ce73604c13
📒 Files selected for processing (41)
api/openapi-internal.yamlapi/openapi.yamlservices/py-help-service/client/cooking_assistant_gen_ai_services_api_internal_client/api/recipe_service/post_ai_nutrients.pyservices/py-help-service/client/cooking_assistant_gen_ai_services_api_internal_client/models/__init__.pyservices/py-help-service/client/cooking_assistant_gen_ai_services_api_internal_client/models/nutrient_request_forwarded.pyservices/py-help-service/client/pyproject.tomlservices/py-recipe-service/client/cooking_assistant_gen_ai_services_api_internal_client/api/recipe_service/post_ai_nutrients.pyservices/py-recipe-service/client/cooking_assistant_gen_ai_services_api_internal_client/models/__init__.pyservices/py-recipe-service/client/cooking_assistant_gen_ai_services_api_internal_client/models/nutrient_request_forwarded.pyservices/py-recipe-service/client/pyproject.tomlservices/py-recipe-service/main.pyservices/py-recipe-service/tests/test_recipe_service.pyservices/spring-api/.openapi-generator/FILESservices/spring-api/src/main/kotlin/org/openapitools/SpringDocConfiguration.ktservices/spring-api/src/main/kotlin/org/openapitools/api/AIApi.ktservices/spring-api/src/main/kotlin/org/openapitools/api/AIApiController.ktservices/spring-api/src/main/kotlin/org/openapitools/api/ApiUtil.ktservices/spring-api/src/main/kotlin/org/openapitools/api/Exceptions.ktservices/spring-api/src/main/kotlin/org/openapitools/api/RecipesApi.ktservices/spring-api/src/main/kotlin/org/openapitools/api/UsersApi.ktservices/spring-api/src/main/kotlin/org/openapitools/internal/client/RecipeServiceApi.ktservices/spring-api/src/main/kotlin/org/openapitools/internal/model/NutrientRequestForwarded.ktservices/spring-api/src/main/kotlin/org/openapitools/model/AuthRequest.ktservices/spring-api/src/main/kotlin/org/openapitools/model/AuthResponse.ktservices/spring-api/src/main/kotlin/org/openapitools/model/ErrorResponse.ktservices/spring-api/src/main/kotlin/org/openapitools/model/HelpRequest.ktservices/spring-api/src/main/kotlin/org/openapitools/model/HelpResponse.ktservices/spring-api/src/main/kotlin/org/openapitools/model/Language.ktservices/spring-api/src/main/kotlin/org/openapitools/model/NutrientRequest.ktservices/spring-api/src/main/kotlin/org/openapitools/model/Recipe.ktservices/spring-api/src/main/kotlin/org/openapitools/model/RecipeCreated.ktservices/spring-api/src/main/kotlin/org/openapitools/model/RecipeIngredient.ktservices/spring-api/src/main/kotlin/org/openapitools/model/RecipeInput.ktservices/spring-api/src/main/kotlin/org/openapitools/model/RecipeNutrients.ktservices/spring-api/src/main/kotlin/org/openapitools/model/RecipeRequest.ktservices/spring-api/src/main/kotlin/org/openapitools/model/RecipeUpdate.ktservices/spring-api/src/main/kotlin/org/openapitools/model/UserCredentials.ktservices/spring-api/src/main/kotlin/org/openapitools/model/UserPreferences.ktservices/spring-api/src/main/kotlin/org/openapitools/model/UserProfile.ktservices/spring-api/src/main/kotlin/org/openapitools/model/UserProfileUpdate.ktweb-client/src/api.ts
|
|
||
| NutrientRequest: | ||
| type: object | ||
| required: [recipe] | ||
| additionalProperties: false | ||
| properties: | ||
| recipe: | ||
| $ref: "#/components/schemas/RecipeInput" | ||
| language: | ||
| $ref: '#/components/schemas/Language' | ||
| description: Optional active language context for any generated metadata text |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Check if the Python nutrient endpoint accepts or uses a language parameter
rg -n -C3 'language' --type py services/py-recipe-service/main.py | head -40Repository: AET-DevOps26/team-devsecops
Length of output: 1432
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== openapi schema around NutrientRequest =="
sed -n '748,776p' api/openapi.yaml
echo
echo "== controller references =="
rg -n -C4 'NutrientRequestForwarded|language|RecipeNutrients|NutrientRequest' api src services -g '!**/node_modules/**' | head -200
echo
echo "== python service context around language usage =="
sed -n '200,240p' services/py-recipe-service/main.pyRepository: AET-DevOps26/team-devsecops
Length of output: 11338
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== internal nutrient schema =="
sed -n '348,366p' api/openapi-internal.yaml
echo
echo "== nutrient controller / forwarding code =="
fd -a 'AIApiController.kt|*Controller.kt|*nutrient*' services src apiRepository: AET-DevOps26/team-devsecops
Length of output: 941
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== controller location =="
fd -a 'AIApiController.kt' .
echo
echo "== controller references to nutrient request =="
rg -n -C4 'NutrientRequestForwarded|NutrientRequest|nutrient|language' services/spring-api -g '*.kt' -g '*.yaml' -g '*.md'
echo
echo "== python service nutrient route/model context =="
rg -n -C4 'nutrient|Nutrient|language' services/py-recipe-service/main.pyRepository: AET-DevOps26/team-devsecops
Length of output: 50383
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== nutrient handler in python service =="
rg -n -C6 'ai/nutrients|nutrient|Nutrient|RecipeNutrients|language' services/py-recipe-service/main.py
echo
echo "== targeted slice around the nutrient route if present =="
python3 - <<'PY'
from pathlib import Path
p = Path('services/py-recipe-service/main.py')
text = p.read_text()
for key in ['`@app.post`("/ai/nutrients")', 'def ai_nutrients', 'def calculate_nutrients', 'NutrientRequest', 'RecipeNutrients']:
idx = text.find(key)
if idx != -1:
start = max(0, text.rfind('\n', 0, idx-300))
end = min(len(text), text.find('\n\n', idx+1) + 2 if text.find('\n\n', idx+1) != -1 else idx+2000)
print(f'--- around {key} ---')
print(text[start:end])
PYRepository: AET-DevOps26/team-devsecops
Length of output: 5331
language is ignored in nutrient generation.
api/openapi.yaml documents it as affecting generated metadata text, but services/spring-api/src/main/kotlin/org/openapitools/api/AIApiController.kt forwards only recipe, and services/py-recipe-service/main.py builds the nutrient prompt from the recipe alone. Either remove language from NutrientRequest, or thread it through the internal request and prompt if it’s meant to matter.
🤖 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 `@api/openapi.yaml` around lines 756 - 766, Resolve the mismatch for
NutrientRequest.language: either remove the language property and its
description from the OpenAPI NutrientRequest schema, or propagate it through
AIApiController into the Python nutrient-generation request and incorporate it
into the prompt construction in main.py. Keep the schema, internal request
model, controller forwarding, and prompt behavior consistent.
| def _build_response( | ||
| *, client: AuthenticatedClient | Client, response: httpx.Response | ||
| ) -> Response[ErrorResponse | RecipeNutrients]: | ||
| return Response( | ||
| status_code=HTTPStatus(response.status_code), | ||
| content=response.content, | ||
| headers=response.headers, | ||
| parsed=_parse_response(client=client, response=response), | ||
| ) |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
rg -n -C3 'HTTPStatus\(response\.status_code\)|class Response' services/py-help-service/clientRepository: AET-DevOps26/team-devsecops
Length of output: 5750
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Inspect the shared response type and the parse/error path.
sed -n '1,220p' services/py-help-service/client/cooking_assistant_gen_ai_services_api_internal_client/types.py
printf '\n--- post_ai_nutrients.py ---\n'
sed -n '1,220p' services/py-help-service/client/cooking_assistant_gen_ai_services_api_internal_client/api/recipe_service/post_ai_nutrients.py
printf '\n--- post_ai_help.py ---\n'
sed -n '1,220p' services/py-help-service/client/cooking_assistant_gen_ai_services_api_internal_client/api/help_service/post_ai_help.py
printf '\n--- get_health.py ---\n'
sed -n '1,180p' services/py-help-service/client/cooking_assistant_gen_ai_services_api_internal_client/api/help_service/get_health.py
printf '\n--- grep UnexpectedStatus / raise_on_unexpected_status ---\n'
rg -n -C2 'UnexpectedStatus|raise_on_unexpected_status|HTTPStatus\(' services/py-help-service/client/cooking_assistant_gen_ai_services_api_internal_clientRepository: AET-DevOps26/team-devsecops
Length of output: 42600
Preserve raw status codes in _build_response.
HTTPStatus(response.status_code) can raise ValueError for non-standard responses like 599, which bypasses the documented raise_on_unexpected_status / UnexpectedStatus path. Keep the raw int here, or relax Response.status_code to accept int.
🤖 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
`@services/py-help-service/client/cooking_assistant_gen_ai_services_api_internal_client/api/recipe_service/post_ai_nutrients.py`
around lines 72 - 80, The `_build_response` function converts every HTTP status
to `HTTPStatus`, which fails for non-standard codes before unexpected-status
handling runs. Preserve `response.status_code` as a raw integer in the
`Response` construction, or update `Response.status_code` to accept arbitrary
integers while maintaining the existing `raise_on_unexpected_status` and
`UnexpectedStatus` behavior.
| override fun aiNutrientsPost( | ||
| @Valid nutrientRequest: org.openapitools.model.NutrientRequest, | ||
| ): ResponseEntity<org.openapitools.model.RecipeNutrients> { | ||
| val internalRequest = | ||
| org.openapitools.internal.model.NutrientRequestForwarded( | ||
| recipe = nutrientRequest.recipe.toInternalRecipe(), | ||
| ) | ||
|
|
||
| val retrofitResponse = | ||
| try { | ||
| recipeServiceApi.aiNutrientsPost("", "", internalRequest).execute() | ||
| } catch (e: InterruptedIOException) { | ||
| throw ResponseStatusException(HttpStatus.GATEWAY_TIMEOUT, "Upstream AI service timed out", e) | ||
| } catch (e: Exception) { | ||
| throw ResponseStatusException(HttpStatus.BAD_GATEWAY, e.message ?: "Upstream service unreachable", e) | ||
| } | ||
|
|
||
| val internalNutrients = handleRetrofitResponse(retrofitResponse) | ||
| val publicNutrients = internalNutrients.toPublicNutrients() | ||
| return ResponseEntity.ok(publicNutrients) | ||
| } |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Check if the Python nutrient endpoint accepts or uses a language parameter
rg -n -C5 'nutrients' --type py services/py-recipe-service/main.py | head -60Repository: AET-DevOps26/team-devsecops
Length of output: 1800
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== Kotlin controller and models =="
rg -n -C4 'aiNutrientsPost|aiRecipesPost|data class NutrientRequest|data class NutrientRequestForwarded|language' services/spring-api/src/main/kotlin/org/openapitools -g '*.kt'
echo
echo "== OpenAPI / schema references =="
rg -n -C3 'NutrientRequest|NutrientRequestForwarded|language' services/spring-api -g '*.yaml' -g '*.yml' -g '*.kt'Repository: AET-DevOps26/team-devsecops
Length of output: 50383
Forward NutrientRequest.language to the nutrient service
aiNutrientsPost builds NutrientRequestForwarded with only recipe, so the public language field is dropped before the Python service sees it. If this endpoint should honor the documented active-language context, add language to the forwarded schema and pass it through here; otherwise remove it from NutrientRequest.
🤖 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 `@services/spring-api/src/main/kotlin/org/openapitools/api/AIApiController.kt`
around lines 101 - 121, Preserve NutrientRequest.language when forwarding
requests from aiNutrientsPost: add a corresponding language field to
NutrientRequestForwarded and populate it from nutrientRequest.language when
constructing the internal request. If language is intentionally unsupported,
remove it from the public NutrientRequest model instead.
Summary
Added endpoint
ai/nutrientswith same specification publicly and internally.Added instructions to use abbreviations for units in the system prompt.
Type of change
API changes
api/openapi.yamlupdated andapi/scripts/gen-all.shre-runDefinition of Done
Summary by CodeRabbit
New Features
Bug Fixes