Skip to content

chore: merge build fixes#2674

Merged
Pratham-Mishra04 merged 1 commit intov1.5.0from
04-13-fix_merge_build_fixes
Apr 13, 2026
Merged

chore: merge build fixes#2674
Pratham-Mishra04 merged 1 commit intov1.5.0from
04-13-fix_merge_build_fixes

Conversation

@Pratham-Mishra04
Copy link
Copy Markdown
Collaborator

Summary

Refactors error handling and response metadata to improve consistency across providers and request types. Replaces the single ModelRequested field with separate OriginalModelRequested and ResolvedModelUsed fields to better track model resolution, and removes redundant provider-specific error metadata population.

Changes

  • Error metadata refactoring: Replaced ModelRequested field with OriginalModelRequested and ResolvedModelUsed in BifrostResponseExtraFields and BifrostErrorExtraFields
  • Provider error handling cleanup: Removed redundant provider, request type, and model metadata from error parsing functions in Mistral and Azure providers
  • OCR error handling: Updated OCR request error responses to include both original and resolved model fields
  • Test updates: Updated test assertions to use new field names
  • Pricing calculation improvements: Fixed duplicate case statement in pricing calculation and corrected variable reference in model catalog logging
  • Azure passthrough simplification: Removed redundant configuration validation and error metadata population
  • OAuth2 context passing: Added missing context parameter to token exchange functions

Type of change

  • Refactor
  • Bug fix
  • Feature
  • Documentation
  • Chore/CI

Affected areas

  • Core (Go)
  • Transports (HTTP)
  • Providers/Integrations
  • Plugins
  • UI (Next.js)
  • Docs

How to test

Validate that error responses and metadata are properly populated:

# Core/Transports
go version
go test ./...

# Test OCR error handling specifically
go test ./core/providers/mistral -run TestOCRWithMockServer
go test ./core -run TestHandleProviderRequest_OCROperationNotAllowed

# Test pricing calculation
go test ./framework/modelcatalog -run TestCalculateCost

Verify that error responses include both original_model_requested and resolved_model_used fields, and that provider-specific error handling works correctly.

Breaking changes

  • Yes
  • No

The ModelRequested field in error and response metadata has been replaced with OriginalModelRequested and ResolvedModelUsed. Clients consuming these fields will need to update their field references.

Related issues

This refactoring improves error handling consistency and model tracking across the codebase.

Security considerations

No security implications - this is primarily a refactoring of internal metadata handling.

Checklist

  • I read docs/contributing/README.md and followed the guidelines
  • I added/updated tests where appropriate
  • I updated documentation where needed
  • I verified builds succeed (Go and UI)
  • I verified the CI pipeline passes locally if applicable

Copy link
Copy Markdown
Collaborator Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 13, 2026

📝 Walkthrough

Summary by CodeRabbit

Release Notes

  • Bug Fixes

    • Fixed OAuth token exchange and refresh operations to properly respect request cancellation and timeouts via context propagation.
  • Chores

    • Updated error response structure to distinguish between originally requested and resolved model identifiers.
    • Simplified provider metadata in passthrough responses.
    • Adjusted real-time request pricing calculation logic.
    • Updated module dependencies.

Walkthrough

This PR refactors model-tracking fields across error responses by replacing ModelRequested with OriginalModelRequested and ResolvedModelUsed. It removes upfront provider configuration validations, simplifies error construction by eliminating provider/model/request-type parameters from error creation, and updates related pricing logic, framework configurations, and handler implementations.

Changes

Cohort / File(s) Summary
Core Model-Tracking Refactoring
core/bifrost.go, core/bifrost_test.go, core/schemas/chatcompletions.go
Updated error ExtraFields to replace ModelRequested with OriginalModelRequested and ResolvedModelUsed fields in OCR request validation errors and chat response conversions.
Mistral Provider Error Handling
core/providers/mistral/errors.go, core/providers/mistral/mistral.go, core/providers/mistral/custom_provider_test.go, core/providers/mistral/ocr_test.go
Simplified ParseMistralError signature by removing requestType, providerName, and model parameters; updated all call sites and removed corresponding ExtraFields population for those metadata fields.
Azure Provider Validation Removal
core/providers/azure/azure.go
Removed upfront configuration validations for Azure key/endpoint and stopped populating ExtraFields (Provider, ModelRequested, RequestType) in passthrough responses. Simplified error creation to omit provider key parameter.
Pricing and Framework Configuration
framework/modelcatalog/main.go, framework/modelcatalog/pricing.go, framework/modelcatalog/pricing_test.go
Updated pricing sync interval logging variable name, modified request-type routing to pass service-tier argument for text cost computation, and changed test setup to use new() pointer initialization and align ExtraFields with new model-tracking field names.
OAuth and Handler Updates
framework/oauth2/main.go, transports/bifrost-http/handlers/asyncinference.go, transports/bifrost-http/handlers/inference.go, transports/bifrost-http/handlers/config.go
Added context passing to OAuth token exchange/refresh functions, updated handlers to pass MCP header combined allowlist to ConvertToBifrostContext, and changed default sync interval fallback constant reference.
Test Infrastructure
transports/bifrost-http/lib/pricing_integration_test.go, plugins/prompts/go.mod
Refactored modelcatalog initialization in integration tests to separate sync-gate setup, updated default sync interval constant reference, and added indirect pgx v5.9.1 dependency.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~65 minutes

Possibly related PRs

  • exception fixes #2659: Updates core/bifrost.go OCRRequest extra-fields and transports/bifrost-http handlers' ConvertToBifrostContext calls with related model-tracking and context refactoring.

Suggested reviewers

  • danpiths

Poem

🐰 The fields dance in fields, old names disappear,
OriginalModelRequested and ResolvedModelUsed are here!
Parameters shed like winter's last snow,
Cleaner, simpler, with less to know ✨

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Title check ⚠️ Warning The title 'chore: merge build fixes' is vague and does not clearly describe the main change of refactoring error handling and response metadata across providers. Use a more descriptive title that captures the primary change, such as 'refactor: split ModelRequested into OriginalModelRequested and ResolvedModelUsed' or 'refactor: improve error metadata consistency across providers'.
Docstring Coverage ⚠️ Warning Docstring coverage is 24.24% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (1 passed)
Check name Status Explanation
Description check ✅ Passed The pull request description comprehensively covers the summary, changes, type of change, affected areas, testing instructions, breaking changes, and includes all relevant checklist items from the template.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 04-13-fix_merge_build_fixes

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

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
framework/modelcatalog/pricing_test.go (1)

193-196: Prefer bifrost.Ptr(...) for these test pointer literals.

These fixtures now mix new(...) into a file that otherwise uses bifrost.Ptr(...). Keeping one style makes the pricing tables much easier to scan, and the same cleanup applies to the other new pointer literals added below.

♻️ Suggested cleanup
-	p.InputCostPerTokenAbove200kTokens = new(0.000006)
-	p.OutputCostPerTokenAbove200kTokens = new(0.00003)
-	p.InputCostPerTokenAbove272kTokens = new(0.000009)
-	p.OutputCostPerTokenAbove272kTokens = new(0.000045)
+	p.InputCostPerTokenAbove200kTokens = bifrost.Ptr(0.000006)
+	p.OutputCostPerTokenAbove200kTokens = bifrost.Ptr(0.00003)
+	p.InputCostPerTokenAbove272kTokens = bifrost.Ptr(0.000009)
+	p.OutputCostPerTokenAbove272kTokens = bifrost.Ptr(0.000045)

Based on learnings: In the maximhq/bifrost repository, prefer using bifrost.Ptr() to create pointers instead of the address operator (&) even when & would be valid syntactically. Apply this consistently across all code paths, including test utilities, to improve consistency and readability.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@framework/modelcatalog/pricing_test.go` around lines 193 - 196, Replace the
new(...) pointer literals with bifrost.Ptr(...) to match existing style: update
p.InputCostPerTokenAbove200kTokens, p.OutputCostPerTokenAbove200kTokens,
p.InputCostPerTokenAbove272kTokens, p.OutputCostPerTokenAbove272kTokens (and any
other newly added pointer literals in this file) to use bifrost.Ptr(value)
instead of new(value), keeping the same numeric values; this ensures consistent
pointer construction with the rest of the test fixtures.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@core/bifrost_test.go`:
- Around line 608-610: The OCR error test currently asserts
err.ExtraFields.OriginalModelRequested but misses validating the new metadata
field ResolvedModelUsed; update the test in core/bifrost_test.go (the failing
block that checks OriginalModelRequested) to also assert
err.ExtraFields.ResolvedModelUsed—if the resolved model is deterministic use an
exact equality assertion for the expected string, otherwise assert that
ResolvedModelUsed is non-empty to prevent silent regressions.

In `@transports/bifrost-http/lib/pricing_integration_test.go`:
- Around line 514-516: Tests currently call modelcatalog.Init(...) then
mc.SetShouldSyncGate(noSyncFunc), which lets Init spawn background syncs before
the gate is set and can cause real HTTP calls; fix by setting the sync gate
before calling modelcatalog.Init (i.e., call SetShouldSyncGate(noSyncFunc) on
the modelcatalog instance or provide the gate to Init) or change Init to
accept/configure the should-sync gate and only start background goroutines
(syncPricing) after that gate is configured; apply this change to the other test
sites that follow the same pattern (the other Init/SetShouldSyncGate usages
referenced in the review).

---

Nitpick comments:
In `@framework/modelcatalog/pricing_test.go`:
- Around line 193-196: Replace the new(...) pointer literals with
bifrost.Ptr(...) to match existing style: update
p.InputCostPerTokenAbove200kTokens, p.OutputCostPerTokenAbove200kTokens,
p.InputCostPerTokenAbove272kTokens, p.OutputCostPerTokenAbove272kTokens (and any
other newly added pointer literals in this file) to use bifrost.Ptr(value)
instead of new(value), keeping the same numeric values; this ensures consistent
pointer construction with the rest of the test fixtures.
🪄 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: 38bf9898-64b5-4686-a8f2-abec595ddd58

📥 Commits

Reviewing files that changed from the base of the PR and between 99bc2a9 and 6998952.

⛔ Files ignored due to path filters (1)
  • plugins/prompts/go.sum is excluded by !**/*.sum
📒 Files selected for processing (17)
  • core/bifrost.go
  • core/bifrost_test.go
  • core/providers/azure/azure.go
  • core/providers/mistral/custom_provider_test.go
  • core/providers/mistral/errors.go
  • core/providers/mistral/mistral.go
  • core/providers/mistral/ocr_test.go
  • core/schemas/chatcompletions.go
  • framework/modelcatalog/main.go
  • framework/modelcatalog/pricing.go
  • framework/modelcatalog/pricing_test.go
  • framework/oauth2/main.go
  • plugins/prompts/go.mod
  • transports/bifrost-http/handlers/asyncinference.go
  • transports/bifrost-http/handlers/config.go
  • transports/bifrost-http/handlers/inference.go
  • transports/bifrost-http/lib/pricing_integration_test.go
💤 Files with no reviewable changes (2)
  • core/providers/mistral/ocr_test.go
  • framework/modelcatalog/pricing.go

Comment thread core/bifrost_test.go
Comment thread transports/bifrost-http/lib/pricing_integration_test.go
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 13, 2026

Greptile encountered an error while reviewing this PR. Please reach out to support@greptile.com for assistance.

Copy link
Copy Markdown
Collaborator Author

Pratham-Mishra04 commented Apr 13, 2026

Merge activity

  • Apr 13, 9:34 AM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Apr 13, 9:35 AM UTC: @Pratham-Mishra04 merged this pull request with Graphite.

@Pratham-Mishra04 Pratham-Mishra04 merged commit ab8973c into v1.5.0 Apr 13, 2026
16 of 18 checks passed
@Pratham-Mishra04 Pratham-Mishra04 deleted the 04-13-fix_merge_build_fixes branch April 13, 2026 09:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants