Add created and updated times to mcp proxy response#1383
Add created and updated times to mcp proxy response#1383RakhithaRR merged 1 commit intowso2:mainfrom
Conversation
WalkthroughThis PR introduces new Application entity types and API endpoints, implements API key mapping for applications, standardizes UTC timestamp handling across repositories, extends MCPProxy with CreatedAt/UpdatedAt fields, and updates the OpenAPI schema to expose these timestamp fields. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
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 Tip CodeRabbit can suggest fixes for GitHub Check annotations.Configure the |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
platform-api/src/internal/service/mcp.go (1)
426-427: Consider usingTimePtrIfNotZeroto gracefully handle uninitialized timestamps.The model's
CreatedAtandUpdatedAtfields are non-pointertime.Timetypes (seemodel/mcp.go:31-32), meaning uninitialized values will be zero (0001-01-01T00:00:00Z). Usingutils.TimePtrwill wrap these zero values into pointers, causing the API to return"0001-01-01T00:00:00Z"instead of omitting the field.While the repository layer now sets timestamps for new records, any legacy data without timestamps could produce awkward responses. Using
utils.TimePtrIfNotZerowould returnnilfor zero times, allowingomitemptyto properly omit the field.♻️ Suggested refactor
- CreatedAt: utils.TimePtr(m.CreatedAt), - UpdatedAt: utils.TimePtr(m.UpdatedAt), + CreatedAt: utils.TimePtrIfNotZero(m.CreatedAt), + UpdatedAt: utils.TimePtrIfNotZero(m.UpdatedAt),Note: The same pattern is used in
mapMCPProxyModelToListItem(lines 448-449) and could be updated for consistency.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@platform-api/src/internal/service/mcp.go` around lines 426 - 427, The mapping uses utils.TimePtr to wrap non-pointer time.Time fields (CreatedAt, UpdatedAt) which will produce pointers to zero timestamps; change these to utils.TimePtrIfNotZero so zero values become nil and are omitted by omitempty. Update both the mapping that sets CreatedAt/UpdatedAt (and the similar code in mapMCPProxyModelToListItem) to call utils.TimePtrIfNotZero instead of utils.TimePtr to avoid returning "0001-01-01T00:00:00Z" for uninitialized times.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@platform-api/src/internal/service/mcp.go`:
- Around line 426-427: The mapping uses utils.TimePtr to wrap non-pointer
time.Time fields (CreatedAt, UpdatedAt) which will produce pointers to zero
timestamps; change these to utils.TimePtrIfNotZero so zero values become nil and
are omitted by omitempty. Update both the mapping that sets CreatedAt/UpdatedAt
(and the similar code in mapMCPProxyModelToListItem) to call
utils.TimePtrIfNotZero instead of utils.TimePtr to avoid returning
"0001-01-01T00:00:00Z" for uninitialized times.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: d4b5da62-6874-4704-9eb4-c175218577b2
📒 Files selected for processing (5)
platform-api/src/api/generated.goplatform-api/src/internal/repository/artifact.goplatform-api/src/internal/repository/mcp.goplatform-api/src/internal/service/mcp.goplatform-api/src/resources/openapi.yaml
Purpose
$subject
Summary by CodeRabbit
Release Notes
New Features
Improvements