Skip to content

Conversation

NullSnow
Copy link

@NullSnow NullSnow commented Aug 26, 2025

  • 在 CreateTranscriptionsReq 类中的 of(File file) 方法中增加了设置文件名的逻辑
  • 解决TranscriptionService中获取文件名为空,导致的接口返回 {"detail":{"logid":"xxxxxxxxxxx"},"code":4000,"msg":"The parameter file is invalid. It should follow the format: file. Please review your input."}

- 在 CreateTranscriptionsReq 类中的 of(File file) 方法中增加了设置文件名的逻辑
- 解决TranscriptionService中获取文件名为空,导致的接口返回 {"detail":{"logid":"2025082610304671C0F5314D04A5EED067"},"code":4000,"msg":"The parameter file is invalid. It should follow the format: file. Please review your input."}
Copy link

coderabbitai bot commented Aug 26, 2025

Walkthrough

Updates the CreateTranscriptionsReq.of(File) factory to also set fileName from the provided File’s name. No other classes or public APIs were changed.

Changes

Cohort / File(s) Summary of Changes
Audio transcription request builder
api/src/main/java/com/coze/openapi/client/audio/transcriptions/CreateTranscriptionsReq.java
Ensure of(File) populates fileName by calling file.getName() when constructing CreateTranscriptionsReq.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

I twitch my whiskers at a tidy tweak,
A name now travels where it used to sneak.
File says “hello,” request says “I see!”
Bytes hop in order, neat as can be.
Thump-thump—ship it! 🐇✨

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • 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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@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: 0

🧹 Nitpick comments (1)
api/src/main/java/com/coze/openapi/client/audio/transcriptions/CreateTranscriptionsReq.java (1)

35-37: Guard against null file and empty filename; prefer clear, actionable failures.

Current code will NPE if file is null, and File#getName() can return an empty string for edge cases (e.g., paths ending with a separator). Add a null check and validate/normalize the derived name to fail fast with a helpful message.

Apply this diff within this method:

   public static CreateTranscriptionsReq of(File file) {
-    return CreateTranscriptionsReq.builder().file(file).fileName(file.getName()).build();
+    java.util.Objects.requireNonNull(file, "file must not be null");
+    String name = file.getName();
+    if (name == null || name.isEmpty()) {
+      java.nio.file.Path p = java.nio.file.Paths.get(file.getPath());
+      java.nio.file.Path fn = p.getFileName();
+      if (fn != null) {
+        name = fn.toString();
+      }
+    }
+    if (name == null || name.isEmpty()) {
+      throw new IllegalArgumentException("File name cannot be empty");
+    }
+    return CreateTranscriptionsReq.builder().file(file).fileName(name).build();
   }

Optional alternative using Lombok to reduce verbosity (requires adding import lombok.NonNull;):

public static CreateTranscriptionsReq of(@NonNull File file) { ... }
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between ffd3528 and a4ff682.

📒 Files selected for processing (1)
  • api/src/main/java/com/coze/openapi/client/audio/transcriptions/CreateTranscriptionsReq.java (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: test (Java 17 on Windows)
  • GitHub Check: test (Java 11 on Windows)
🔇 Additional comments (2)
api/src/main/java/com/coze/openapi/client/audio/transcriptions/CreateTranscriptionsReq.java (2)

35-37: Good fix: populating fileName in of(File) addresses the backend 400 for empty filename.

Setting fileName from file.getName() is the right behavior for multipart uploads and should resolve the reported "The parameter file is invalid" error when the filename was previously omitted.


35-37: Content-Disposition filename is correctly wired through

Verified that when using CreateTranscriptionsReq.of(File file), the fileName set on the request is indeed passed into the multipart builder as the Content-Disposition filename:

  • In api/src/main/java/com/coze/openapi/service/service/file/FileService.java line 61, the code calls
    MultipartBody.Part.createFormData("file", filename, requestFile)
    where filename is the second argument passed from req.getFileName().
  • In api/src/main/java/com/coze/openapi/service/service/audio/TranscriptionService.java line 48, within the private uploadFile(...) helper, it likewise calls
    MultipartBody.Part.createFormData("file", filename, requestFile)
    with filename coming from req.getFileName().

Because CreateTranscriptionsReq.of(File file) sets fileName to file.getName(), this ensures the downstream multipart upload uses the correct filename and will satisfy the API’s Content-Disposition requirement. No further changes are needed.

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.

1 participant