Skip to content

fix(inference): include model field in nvidia-nim API requests (#2784)#2824

Closed
sanil-23 wants to merge 1 commit into
tinyhumansai:mainfrom
sanil-23:fix/2784-nvidia-nim-model-field
Closed

fix(inference): include model field in nvidia-nim API requests (#2784)#2824
sanil-23 wants to merge 1 commit into
tinyhumansai:mainfrom
sanil-23:fix/2784-nvidia-nim-model-field

Conversation

@sanil-23
Copy link
Copy Markdown
Contributor

Closes #2784

Root cause

In make_cloud_provider_by_slug (factory.rs), when a provider string like "nvidia-nim:" was used (slug with empty model after the colon), the effective model resolution fell through to entry.default_model.clone().unwrap_or_default(). If the cloud provider entry had no default_model configured, this produced an empty string "", which was then sent as the model field in the OpenAI-compatible /v1/chat/completions request body, causing a 400 error ("model field is required").

Fix

Added a two-level fallback chain in make_cloud_provider_by_slug:

  1. Try config.default_model (the user's top-level default model setting)
  2. Fall back to the global DEFAULT_MODEL constant (reasoning-quick-v1)

This mirrors the same fallback pattern already used by cloud_entry_provider_string (the sibling function that builds provider strings for the primary cloud route).

Verified

  • cargo check -p openhuman — compiles cleanly
  • All 78 factory unit tests pass
  • All 91 compatible-provider unit tests pass

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 28, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 8fda9b7d-48d6-4132-96de-f1211cf2989d

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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

Copy link
Copy Markdown
Contributor

@oxoxDev oxoxDev left a comment

Choose a reason for hiding this comment

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

Author: @sanil-23 (MEMBER — core team)

⚠️ Duplicate of in-flight PR #2791 by @graycyrus — same root cause, same function (make_cloud_provider_by_slug in src/openhuman/inference/provider/factory.rs), identical title. #2791 was opened 11 days earlier and already has coderabbit approval. Issue #2784 is assigned to @graycyrus.

Surfacing as COMMENT (not blocking with CHANGES_REQUESTED) so you can coordinate with @graycyrus on which approach to land:

Comparison

Aspect #2791 (graycyrus) #2824 (this PR)
Files factory.rs + config_rejection.rs + factory_test.rs factory.rs only
Fallback chain entry.default_modelbail with actionable error entry.default_modelconfig.default_modelDEFAULT_MODEL constant (silent)
Sentry guard Adds "model field is required" to config_rejection classifier (suppresses TAURI-RUST-4NM) None
Tests 3 unit tests None
AuthStyle::OpenhumanJwt exemption Yes No
Failure mode Loud, surfaces config bug Silent — masks misconfig

Concerns (independent of duplicate question)

  1. factory.rs:779 — silent DEFAULT_MODEL fallback masks misconfiguration. reasoning-quick-v1 is openhuman's abstract tier (Kimi K2.6 Turbo on Fireworks), NOT an nvidia-nim-native model. When the chain hits the third arm with slug=nvidia-nim, the request hits nvidia-nim's /v1/chat/completions with model=reasoning-quick-v1 — model nvidia-nim does not host → 404. Replaces a 400 with a different cryptic 4xx; user has zero signal their config is wrong.

  2. No regression tests. Coverage gate (≥80% on changed lines) and #2784's AC ("Unit test added to verify model field is present in nvidia-nim request payloads") — neither met.

  3. Missing AuthStyle::OpenhumanJwt guard. make_openhuman_backend derives its model from config.default_model independently — the third-arm DEFAULT_MODEL rescue is dead code for openhuman entries and masks an honest empty for misconfigured auth_style cases. #2791 gates this with if entry.auth_style != AuthStyle::OpenhumanJwt && effective_model.trim().is_empty().

  4. No config_rejection.rs update. TAURI-RUST-4NM Sentry events from older clients with bad configs will keep firing post-deploy until install base rotates. #2791 adds "model field is required" to is_provider_config_rejection_message precisely to silence this.

Recommendation

Close #2824 in favour of #2791 (more complete, has tests, fails loudly, by ticket assignee). If you want the global-DEFAULT layer for some other reason, add it onto #2791's tail. Per [[feedback_check_open_prs_before_implement]] — checking open PRs against #2784 would have caught the overlap before opening.

Happy to flip to APPROVE / CHANGES_REQUESTED once you decide. Not blocking with formal review state yet.

Verified / looks good

  • .filter(|m| !m.trim().is_empty()) guards correctly handle whitespace-only default_model strings — actual hardening over main's unwrap_or_default() which only handles None.
  • crate::openhuman::config::DEFAULT_MODEL path resolves (src/openhuman/config/schema/types.rs:37).
  • CI green (2 e2e + 1 coverage-gate pending), no formatting/clippy issues.

@sanil-23
Copy link
Copy Markdown
Contributor Author

Thanks for the side-by-side @oxoxDev — agreed, #2791 is the right landing (loud bail!, tests, AuthStyle::OpenhumanJwt guard, config_rejection.rs silencer for TAURI-RUST-4NM). The silent DEFAULT_MODEL fallback here would just trade a 400 for a 404 against nvidia-nim's /v1/chat/completions.

Closing in favor of @graycyrus's #2791. Should have checked open PRs against issue #2784 before opening — apologies for the noise.

@sanil-23 sanil-23 closed this May 28, 2026
@sanil-23 sanil-23 deleted the fix/2784-nvidia-nim-model-field branch May 28, 2026 13:26
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.

nvidia-nim provider omits model field in API requests, causing 400 errors

2 participants