Skip to content

Return error when model price/ratio unset - #3081

Merged
Calcium-Ion merged 1 commit into
QuantumNous:mainfrom
BenLampson:main
Mar 2, 2026
Merged

Return error when model price/ratio unset#3081
Calcium-Ion merged 1 commit into
QuantumNous:mainfrom
BenLampson:main

Conversation

@BenLampson

@BenLampson BenLampson commented Mar 2, 2026

Copy link
Copy Markdown
Contributor

#3079
将 ModelPriceHelperPerCall 辅助函数的返回值修改为 (PriceData, error),并停止静默回退到默认价格。若模型价格未配置,该辅助函数现在会返回错误(除非用户已启用 AcceptUnsetRatioModel 且存在对应比例)。
将此错误传播给调用方:Midjourney 处理器现在会返回一个 Code 为 4 且包含错误信息的 MidjourneyResponse;任务提交则会返回一个包装后的任务错误,并附带 HTTP 400 状态码。
此外,在 ResolveOriginTask 中为 remix 操作提取 video_id。
此修改强制要求显式配置模型价格 / 比例,并将配置问题暴露给客户端。

QuantumNous#3079
Change ModelPriceHelperPerCall to return (PriceData, error) and stop silently falling back to a default price. If a model price is not configured the helper now returns an error (unless the user has AcceptUnsetRatioModel enabled and a ratio exists). Propagate this error to callers: Midjourney handlers now return a MidjourneyResponse with Code 4 and the error message, and task submission returns a wrapped task error with HTTP 400. Also extract remix video_id in ResolveOriginTask for remix actions. This enforces explicit model price/ratio configuration and surfaces configuration issues to clients.
@coderabbitai

coderabbitai Bot commented Mar 2, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0689600 and 4b439ad.

📒 Files selected for processing (3)
  • relay/helper/price.go
  • relay/mjproxy_handler.go
  • relay/relay_task.go

Walkthrough

The PR updates the price helper function to return an error in addition to price data, enabling proper error propagation for missing configuration. Callers are updated to handle these errors, returning appropriate error responses instead of proceeding with invalid data.

Changes

Cohort / File(s) Summary
Price Helper Function
relay/helper/price.go
Modified ModelPriceHelperPerCall signature to return (PriceData, error). Added validation errors for missing default price and missing model ratio configurations, replacing previous silent defaults with explicit error propagation.
Midjourney Handler
relay/mjproxy_handler.go
Updated calls to ModelPriceHelperPerCall in RelaySwapFace and RelayMidjourneySubmit to handle error returns, responding with Midjourney error Code 4 on price helper failures.
Task Relay & Remix Handling
relay/relay_task.go
Added remix video_id extraction in ResolveOriginTask for remix detection. Updated RelayTaskSubmit to explicitly handle ModelPriceHelperPerCall errors, returning TaskErrorWrapper with code "model_price_error" and HTTP 400 on failure.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • creamlike1024
  • xyfacai

Poem

🐰 A helper's tale of prices true,
With errors caught and handled too,
No silent fails to haunt the night,
Just honest errors, shining bright! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Return error when model price/ratio unset' directly and accurately describes the main change: modifying ModelPriceHelperPerCall to return an error when model price or ratio configuration is missing, rather than silently using defaults.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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 and usage tips.

@Calcium-Ion
Calcium-Ion merged commit d36f420 into QuantumNous:main Mar 2, 2026
1 check passed
ennnnny pushed a commit to ennnnny/new-api that referenced this pull request Mar 17, 2026
Return error when model price/ratio unset
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.

2 participants