Skip to content

Fix OpenAI response created timestamp - #16401

Merged
yuzhichang merged 18 commits into
infiniflow:mainfrom
Harsh23Kashyap:Harsh23Kashyap/fix/openai-created-timestamp
Jul 6, 2026
Merged

yuzhichang merged 18 commits into
infiniflow:mainfrom
Harsh23Kashyap:Harsh23Kashyap/fix/openai-created-timestamp

Conversation

@Harsh23Kashyap

Copy link
Copy Markdown
Collaborator

What this fixes

Closes #16400.

get_data_openai() currently returns created: null when callers do not pass a timestamp, and it replaces explicit timestamp values with the current time. This makes non-streaming OpenAI-compatible responses inconsistent with the expected integer created timestamp field.

Change

  • Preserve explicit created values when provided.
  • Default non-streaming responses to int(time.time()) when created is not provided.
  • Add focused unit coverage for default timestamps, explicit timestamps, and unchanged streaming chunk shape.

Verification

  • ./.venv/bin/python -m pytest test/unit_test/api/utils/test_api_utils.py -q
  • python3 -m py_compile api/utils/api_utils.py test/unit_test/api/utils/test_api_utils.py
  • uvx ruff check api/utils/api_utils.py test/unit_test/api/utils/test_api_utils.py

@dosubot dosubot Bot added size:XS This PR changes 0-9 lines, ignoring generated files. 🌈 python Pull requests that update Python code 🐞 bug Something isn't working, pull request that fix bug. 🧪 test Pull requests that update test cases. labels Jun 27, 2026
@coderabbitai

coderabbitai Bot commented Jun 27, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

get_data_openai now defaults created to the current Unix timestamp when omitted, preserves explicit values, and adds tests for the default, explicit, and stream response shapes.

Changes

OpenAI response timestamp handling

Layer / File(s) Summary
Created default handling
api/utils/api_utils.py
get_data_openai now uses int(time.time()) when created is None and preserves provided values.
Response tests
test/unit_test/api/utils/test_api_utils.py
Tests cover default timestamp generation, explicit created preservation, and the stream=True response shape.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

(_/)
(•ㅅ•) I hopped through the code today,
/   づ and timestamps found their way.
No nulls for brunch, just time that sings,
while streamy chunks keep their neat little wings.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.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
Title check ✅ Passed The title clearly matches the main change: fixing the OpenAI response created timestamp handling.
Description check ✅ Passed The description covers the problem, fix, and verification, though it uses a custom heading instead of the template's exact Summary section.
Linked Issues check ✅ Passed The code and tests satisfy #16400 by preserving explicit created values, defaulting to int(time.time()), and leaving streaming shape unchanged.
Out of Scope Changes check ✅ Passed The changes stay focused on the timestamp fix and related tests without introducing unrelated scope.

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

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 `@test/unit_test/api/utils/test_api_utils.py`:
- Around line 28-31: Update test_get_data_openai to cover the falsy
explicit-value regression by asserting that api_utils.get_data_openai preserves
an explicitly passed created value of 0, not just a truthy value like 123. Keep
the focus on the get_data_openai behavior so the test would fail if the old
truthiness check returns a default instead of the provided value.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 02d3c2c1-6efc-4e3a-a11b-552f301fc407

📥 Commits

Reviewing files that changed from the base of the PR and between 70546ea and 19dfbe8.

📒 Files selected for processing (2)
  • api/utils/api_utils.py
  • test/unit_test/api/utils/test_api_utils.py

@yuzhichang
yuzhichang force-pushed the main branch 2 times, most recently from 78db4e9 to f86a0e7 Compare June 29, 2026 01:47
@yuzhichang
yuzhichang force-pushed the Harsh23Kashyap/fix/openai-created-timestamp branch from fc5ba9c to f372b99 Compare June 29, 2026 06:12
@Harsh23Kashyap

Copy link
Copy Markdown
Collaborator Author

Synced with latest main. Could a maintainer add the ci label so workflows can run? Okay, please review it.

@Harsh23Kashyap
Harsh23Kashyap force-pushed the Harsh23Kashyap/fix/openai-created-timestamp branch from 50cc40b to 9fd0b19 Compare June 30, 2026 04:48
@Harsh23Kashyap
Harsh23Kashyap force-pushed the Harsh23Kashyap/fix/openai-created-timestamp branch from 96dc199 to e76ec16 Compare June 30, 2026 13:44
@Harsh23Kashyap

Copy link
Copy Markdown
Collaborator Author

Follow-up: branch is current with main (behind_by: 0). CodeRabbit passed; no unresolved review threads. Fork workflows are still skipped until a maintainer adds the ci label. Ready for review when you have a chance.

@Harsh23Kashyap

Copy link
Copy Markdown
Collaborator Author

Can someone take a look when you have a chance?

@yuzhichang yuzhichang left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Jul 6, 2026
@yuzhichang yuzhichang added the ci Continue Integration label Jul 6, 2026
@codecov

codecov Bot commented Jul 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.16%. Comparing base (8b065d3) to head (bca833d).
⚠️ Report is 6 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #16401      +/-   ##
==========================================
- Coverage   94.56%   93.16%   -1.40%     
==========================================
  Files          10       10              
  Lines         717      717              
  Branches      118      118              
==========================================
- Hits          678      668      -10     
- Misses         25       29       +4     
- Partials       14       20       +6     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@yuzhichang
yuzhichang merged commit 98189cd into infiniflow:main Jul 6, 2026
9 checks passed
@Harsh23Kashyap Harsh23Kashyap mentioned this pull request Jul 7, 2026
1 of 6 tasks
yuzhichang pushed a commit that referenced this pull request Jul 8, 2026
@Harsh23Kashyap
Harsh23Kashyap deleted the Harsh23Kashyap/fix/openai-created-timestamp branch July 17, 2026 11:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐞 bug Something isn't working, pull request that fix bug. ci Continue Integration lgtm This PR has been approved by a maintainer 🌈 python Pull requests that update Python code size:XS This PR changes 0-9 lines, ignoring generated files. 🧪 test Pull requests that update test cases.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: OpenAI-compatible responses return created as null by default

2 participants