feat: jimeng apiKey format to use | delimiter - #1322
Conversation
WalkthroughThe changes update the expected API key format from a comma-separated ("access_key,secret_key") to a pipe-separated ("access_key|secret_key") string in both backend and frontend components. The backend parsing and error messages are revised, and the frontend prompt for the relevant input type is updated to instruct users on the new format. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Frontend
participant Backend
User->>Frontend: Enter API key in "access_key|secret_key" format
Frontend->>Backend: Send API key as part of request
Backend->>Backend: Parse API key using pipe separator
Backend-->>Frontend: Process task or return error if format invalid
Frontend-->>User: Show result or error message
Possibly related PRs
Poem
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
relay/channel/task/jimeng/adaptor.go(2 hunks)web/src/pages/Channel/EditChannel.js(1 hunks)
🔇 Additional comments (2)
relay/channel/task/jimeng/adaptor.go (2)
80-81: LGTM: API key parsing updated to use pipe delimiter.The comment and parsing logic are correctly updated to use the pipe delimiter. The change is consistent with the PR objective.
195-197: Verify backward compatibility for Jimeng API key delimiterThe adapter now only accepts “ak|sk” and will reject any comma-separated keys. Our grep across
relay/channel/task/jimengand related constants didn’t uncover any built-in support for comma delimiters, but please double-check how existing deployments supply the Jimeng key (e.g., env vars, DB records, Helm values) to ensure this won’t break users.• File to review:
– relay/channel/task/jimeng/adaptor.go (around lines 195–197)• If you need to support both formats during migration, you can add a fallback:
- keyParts := strings.Split(key, "|") - if len(keyParts) != 2 { - return nil, fmt.Errorf("invalid api key format for jimeng: expected 'ak|sk'") + var keyParts []string + switch { + case strings.Contains(key, "|"): + keyParts = strings.Split(key, "|") + case strings.Contains(key, ","): + keyParts = strings.Split(key, ",") + default: + return nil, fmt.Errorf("invalid api key format for jimeng: expected 'ak|sk' or 'ak,sk'") + } + if len(keyParts) != 2 { + return nil, fmt.Errorf("invalid api key format for jimeng: expected 'ak|sk' or 'ak,sk'") } accessKey := strings.TrimSpace(keyParts[0]) secretKey := strings.TrimSpace(keyParts[1])Please confirm your existing configurations and rollout plans before shipping this change.
| case 51: | ||
| return '按照如下格式输入: Access Key ID|Secret Access Key'; |
There was a problem hiding this comment.
💡 Verification agent
🧩 Analysis chain
Frontend prompt correctly aligned with backend format.
The new case 51 provides the appropriate user prompt for the pipe-separated API key format, matching the backend expectation. The prompt text is consistent with other similar cases in the function.
Verify that channel type 51 corresponds to the jimeng channel:
🏁 Script executed:
#!/bin/bash
# Description: Verify that channel type 51 is used for jimeng
# Expected: Find confirmation that type 51 maps to jimeng channel
# Search for channel type definitions or mappings
echo "=== Searching for channel type definitions ==="
rg -i "jimeng.*51|51.*jimeng" -A 3 -B 3
# Search for CHANNEL_OPTIONS or similar constants
echo "=== Searching for channel options/types ==="
rg "CHANNEL_OPTIONS|channel.*type" --type js -A 10 -B 5Length of output: 10597
🏁 Script executed:
#!/bin/bash
echo "=== Searching for ChannelTypeJimeng usage in Go code ==="
rg -n -A3 -B3 'ChannelTypeJimeng' --type goLength of output: 1027
🏁 Script executed:
#!/bin/bash
echo "=== Extracting type2secretPrompt function ==="
rg -n 'type2secretPrompt' -A15 -B5 web/src/pages/Channel/EditChannel.jsLength of output: 1765
Unify punctuation in type2secretPrompt for consistency
The new prompts for cases 50 and 51 use an ASCII colon and (in case 50) include a space after it, whereas all earlier cases use a Chinese full-width colon (:) with no space. To keep the UI copy consistent, please update both to use : and remove the extra space:
• File: web/src/pages/Channel/EditChannel.js
– Around lines 68–71
case 50:
- return '按照如下格式输入: AccessKey|SecretKey';
+ return '按照如下格式输入:AccessKey|SecretKey';
case 51:
- return '按照如下格式输入: Access Key ID|Secret Access Key';
+ return '按照如下格式输入:Access Key ID|Secret Access Key';📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| case 51: | |
| return '按照如下格式输入: Access Key ID|Secret Access Key'; | |
| case 50: | |
| return '按照如下格式输入:AccessKey|SecretKey'; | |
| case 51: | |
| return '按照如下格式输入:Access Key ID|Secret Access Key'; |
🤖 Prompt for AI Agents
In web/src/pages/Channel/EditChannel.js around lines 68 to 71, the prompt
strings for cases 50 and 51 use an ASCII colon and inconsistent spacing, while
earlier cases use a Chinese full-width colon without a space. Update these
prompt strings to replace the ASCII colon with a Chinese full-width colon (:)
and remove any extra spaces after the colon to unify punctuation and maintain UI
consistency.
…limiter feat: jimeng apiKey format to use `|` delimiter
增加即梦渠道的Access Key ID 和 Secret Access Key使用
|分隔的提示,保持和其他渠道格式一致Summary by CodeRabbit
New Features
Bug Fixes