Skip to content

ECOPROJECT-4807 | feat: add created_at timestamp to inventory schema - #1377

Open
nirarg wants to merge 1 commit into
kubev2v:mainfrom
nirarg:ECOPROJECT-4807-inventory-created-at
Open

ECOPROJECT-4807 | feat: add created_at timestamp to inventory schema#1377
nirarg wants to merge 1 commit into
kubev2v:mainfrom
nirarg:ECOPROJECT-4807-inventory-created-at

Conversation

@nirarg

@nirarg nirarg commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Adds a created_at field to the Inventory OpenAPI schema (inside the JSONB blob stored in snapshots), so assessments can track when inventory data was originally created or collected
  • For RVTools and agent paths, the timestamp is set automatically by BuildInventory() at processing/collection time
  • For direct inventory uploads and agent pushes, the server injects time.Now() if the caller omits the field
  • Field is optional for backward compatibility — existing data deserializes with created_at: null

Changes

File Change
api/v1alpha1/openapi.yaml Added optional created_at field to Inventory schema
pkg/inventory/model.go Added CreatedAt *time.Time to domain model
pkg/inventory/converters/to_api.go Maps CreatedAt in ToAPI()
pkg/duckdb_parser/inventory_builder.go Sets CreatedAt in BuildInventory()
internal/handlers/v1alpha1/mappers/inbound.go Injects timestamp for direct inventory uploads
internal/handlers/v1alpha1/agent.go Injects timestamp for agent inventory pushes
pkg/inventory/converters/to_api_test.go Tests for CreatedAt mapping

Test plan

  • make lint passes
  • make unit-test passes (all 21 suites, including new converter tests)
  • New test cases verify CreatedAt propagation (set and nil)
  • Verify backward compatibility: existing assessments without created_at still deserialize correctly

Fixes: ECOPROJECT-4807

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Inventory records now include an optional creation timestamp.
    • Inventory creation and update operations automatically record the current UTC time when no timestamp is provided.
    • Inventory timestamps are included consistently in API responses and related form data.
  • API Improvements

    • Added the created_at date-time field to the Inventory API schema.
    • Existing inventory data without a timestamp remains supported.

@nirarg
nirarg requested a review from a team as a code owner July 30, 2026 06:10
@nirarg
nirarg requested review from AvielSegev and amalimov and removed request for a team July 30, 2026 06:10
@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 9d773603-7320-48a7-85bb-67f8b6a87569

📥 Commits

Reviewing files that changed from the base of the PR and between dc65e6f and 664acb1.

📒 Files selected for processing (10)
  • api/v1alpha1/agent/spec.gen.go
  • api/v1alpha1/openapi.yaml
  • api/v1alpha1/spec.gen.go
  • api/v1alpha1/types.gen.go
  • internal/handlers/v1alpha1/agent.go
  • internal/handlers/v1alpha1/mappers/inbound.go
  • pkg/duckdb_parser/inventory_builder.go
  • pkg/inventory/converters/to_api.go
  • pkg/inventory/converters/to_api_test.go
  • pkg/inventory/model.go

📝 Walkthrough

Walkthrough

Adds an optional CreatedAt timestamp to inventory models and API schemas. Inventory creation and update paths populate missing values with the current UTC time. API conversion preserves the timestamp, and tests cover present and nil values.

Changes

Inventory creation timestamp

Layer / File(s) Summary
Inventory timestamp contract
pkg/inventory/model.go, api/v1alpha1/types.gen.go, api/v1alpha1/openapi.yaml, pkg/inventory/converters/to_api.go, api/v1alpha1/spec.gen.go, api/v1alpha1/agent/spec.gen.go
Adds optional CreatedAt and created_at fields, maps the domain value to API output, and refreshes embedded specifications.
Timestamp population paths
pkg/duckdb_parser/inventory_builder.go, internal/handlers/v1alpha1/agent.go, internal/handlers/v1alpha1/mappers/inbound.go
Sets the current UTC time when inventory is created or updated without an existing timestamp.
Timestamp conversion validation
pkg/inventory/converters/to_api_test.go
Tests timestamp preservation and nil handling during API conversion.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Suggested reviewers: avielsegev, amalimov

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely identifies the addition of the created_at timestamp to the inventory schema.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@nirarg

nirarg commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator Author

/hold

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 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/v1alpha1/openapi.yaml`:
- Around line 2316-2319: Update the created_at property in the OpenAPI schema to
explicitly allow null values by adding nullable: true, then regenerate all
embedded/generated specifications so the schema and generated artifacts remain
consistent.
🪄 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: ASSERTIVE

Plan: Pro Plus

Run ID: bfaff689-600e-443e-a160-bd0f65bbd189

📥 Commits

Reviewing files that changed from the base of the PR and between 8861749 and 2d16684.

📒 Files selected for processing (10)
  • api/v1alpha1/agent/spec.gen.go
  • api/v1alpha1/openapi.yaml
  • api/v1alpha1/spec.gen.go
  • api/v1alpha1/types.gen.go
  • internal/handlers/v1alpha1/agent.go
  • internal/handlers/v1alpha1/mappers/inbound.go
  • pkg/duckdb_parser/inventory_builder.go
  • pkg/inventory/converters/to_api.go
  • pkg/inventory/converters/to_api_test.go
  • pkg/inventory/model.go

Comment thread api/v1alpha1/openapi.yaml
Comment on lines +2316 to +2319
created_at:
type: string
format: date-time
description: Timestamp when the inventory data was created or collected

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Allow explicit null for backward compatibility.

created_at is optional but not nullable, so schema-aware clients or validators can reject existing payloads containing "created_at": null, even though the generated Go pointer accepts it. Add nullable: true and regenerate the embedded specifications.

This follows the PR objective that existing data may deserialize with created_at: null.

Proposed schema fix
         created_at:
           type: string
           format: date-time
+          nullable: true
           description: Timestamp when the inventory data was created or collected
📝 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.

Suggested change
created_at:
type: string
format: date-time
description: Timestamp when the inventory data was created or collected
created_at:
type: string
format: date-time
nullable: true
description: Timestamp when the inventory data was created or collected
🤖 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/v1alpha1/openapi.yaml` around lines 2316 - 2319, Update the created_at
property in the OpenAPI schema to explicitly allow null values by adding
nullable: true, then regenerate all embedded/generated specifications so the
schema and generated artifacts remain consistent.

@nirarg
nirarg force-pushed the ECOPROJECT-4807-inventory-created-at branch from 2d16684 to 1b6fb9a Compare August 5, 2026 05:30
@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 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 `@pkg/duckdb_parser/inventory_builder.go`:
- Around line 78-84: Add regression tests covering nil CreatedAt defaults and
preservation of an existing CreatedAt value for BuildInventory in
pkg/duckdb_parser/inventory_builder.go:78-84, the inbound mapper in
internal/handlers/v1alpha1/mappers/inbound.go:191-194, and each affected agent
handler site in internal/handlers/v1alpha1/agent.go:43-46, 99-102, and 154-157;
assert that nil inputs receive a timestamp while pre-populated timestamps remain
unchanged.
🪄 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: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 86eaef8c-db2b-464c-b41e-eb7b4014229f

📥 Commits

Reviewing files that changed from the base of the PR and between 1894b55 and 1b6fb9a.

📒 Files selected for processing (10)
  • api/v1alpha1/agent/spec.gen.go
  • api/v1alpha1/openapi.yaml
  • api/v1alpha1/spec.gen.go
  • api/v1alpha1/types.gen.go
  • internal/handlers/v1alpha1/agent.go
  • internal/handlers/v1alpha1/mappers/inbound.go
  • pkg/duckdb_parser/inventory_builder.go
  • pkg/inventory/converters/to_api.go
  • pkg/inventory/converters/to_api_test.go
  • pkg/inventory/model.go

Comment thread pkg/duckdb_parser/inventory_builder.go
@AvielSegev

Copy link
Copy Markdown
Collaborator

/approve

@openshift-ci

openshift-ci Bot commented Aug 6, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: AvielSegev

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci Bot added the approved label Aug 6, 2026
Adds a created_at field to the Inventory schema (inside the JSONB blob)
so assessments can track when inventory data was originally collected.

For RVTools and agent paths, the timestamp is set automatically by
BuildInventory(). For direct inventory uploads and agent pushes, the
server injects time.Now() if the caller omits it.

Co-Authored-By: Claude Code <noreply@anthropic.com>
Signed-off-by: Nir Argaman <nargaman@redhat.com>
@nirarg
nirarg force-pushed the ECOPROJECT-4807-inventory-created-at branch from 1b6fb9a to 664acb1 Compare August 7, 2026 01:20
@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants