Skip to content

fix(cli): ov chat auth from config with required headers#1575

Merged
qin-ctx merged 1 commit intovolcengine:mainfrom
tolatolatop:fix/ov-chat-auth
Apr 20, 2026
Merged

fix(cli): ov chat auth from config with required headers#1575
qin-ctx merged 1 commit intovolcengine:mainfrom
tolatolatop:fix/ov-chat-auth

Conversation

@tolatolatop
Copy link
Copy Markdown
Contributor

Summary

Fixes #1574

This PR fixes ov chat command failing with 401 Unauthorized even when valid credentials are configured in ovcli.conf.

Problem

ov chat was not reading api_key, account, and user from the configuration file, and was not sending the required X-OpenViking-Account and X-OpenViking-User headers for API_KEY auth mode.

Changes

1. crates/ov_cli/src/commands/chat.rs

  • Added account and user CLI arguments to ChatCommand
  • Added ChatAuth struct to hold resolved authentication info
  • Added resolve_auth() method to load auth from Config when not provided via CLI
  • Added apply_auth_headers() helper to send all required headers
  • Updated all send_message* methods to use the new auth flow

2. crates/ov_cli/src/config.rs

  • Added #[serde(alias = "account_id")] on account field
  • Added #[serde(alias = "user_id")] on user field
  • Added test for deserializing account_id/user_id aliases

3. crates/ov_cli/src/main.rs

  • Pass account and user from ctx.config to ChatCommand construction

Testing

Before:

$ ov chat -m "hello"
Error: API error: Request failed (401 Unauthorized): Missing API Key...

After:

$ ov chat -m "hello"
Bot:
Hello! I'm VikingBot, an AI assistant built on the OpenViking...

Checklist

  • Code compiles (cargo build --release -p ov_cli)
  • Fix verified by testing ov chat command
  • Backward compatible (CLI args override config values)
  • Supports both account/user and account_id/user_id field names

AI Assistant Note: This fix was identified through code analysis by Hermes Agent with Codex tooling. See #1574 for full investigation details.

- chat.rs: Load api_key/account/user from Config when not provided via CLI
- chat.rs: Add X-OpenViking-Account and X-OpenViking-User headers
- config.rs: Add serde aliases for account_id/user_id field names
- main.rs: Pass account/user from config to ChatCommand

Fixes volcengine#1574
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 19, 2026

CLA assistant check
All committers have signed the CLA.

@github-actions
Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis ✅

1574 - Fully compliant

Compliant requirements:

  • Fix ov chat ignoring api_key/account/user from ovcli.conf
  • Ensure ov chat sends X-API-Key, X-OpenViking-Account, X-OpenViking-User headers
  • Support both account/user and account_id/user_id config field names
⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🏅 Score: 90
🧪 PR contains tests
🔒 No security concerns identified
✅ No TODO sections
🔀 No multiple PR themes
⚡ No major issues detected

@github-actions
Copy link
Copy Markdown

PR Code Suggestions ✨

No code suggestions found for the PR.

@qin-ctx
Copy link
Copy Markdown
Collaborator

qin-ctx commented Apr 20, 2026

Thanks for your contribution. May I ask whether the conversation works properly after the fix? Could you also share a screenshot showing a normal response?

@qin-ctx qin-ctx merged commit b19631f into volcengine:main Apr 20, 2026
2 checks passed
@github-project-automation github-project-automation Bot moved this from Backlog to Done in OpenViking project Apr 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[Bug]: ov chat ignores api_key/account/user from ovcli.conf causing 401 Unauthorized

3 participants