Skip to content

Conversation

@lefarcen
Copy link
Contributor

@lefarcen lefarcen commented Dec 10, 2025

…te drive service skip condition.

Summary

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.

Tip

Close issue syntax: Fixes #<issue number> or Resolves #<issue number>, see documentation for more details.

Impact Areas

Please check the areas this PR affects:

  • Multi-threaded Dialogues
  • AI-Powered Capabilities (Web Search, Knowledge Base Search, Question Recommendations)
  • Context Memory & References
  • Knowledge Base Integration & RAG
  • Quotes & Citations
  • AI Document Editing & WYSIWYG
  • Free-form Canvas Interface
  • Other

Screenshots/Videos

Before After
... ...

Checklist

Important

Please review the checklist below before submitting your pull request.

  • This change requires a documentation update, included: Refly Documentation
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.
  • I ran dev/reformat(backend) and cd web && npx lint-staged(frontend) to appease the lint gods

Summary by CodeRabbit

  • Bug Fixes

    • Fixed file upload processing to correctly handle buffer-based uploads that were previously skipped.
  • Improvements

    • Data URLs are now stored/handled as binary buffers for more efficient uploads.
    • Generated content URLs now use the configured endpoint, improving link consistency.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Dec 10, 2025

Walkthrough

Renames origin→endpoint in drive DTOs and DriveService, adds a private endpoint getter and uses it in DTO construction, enables buffer-based upload path in DriveService batch processing, and decodes data-URL base64 into a Buffer in resource.service before creating DriveFile.

Changes

Cohort / File(s) Change Summary
Drive service update
apps/api/src/modules/drive/drive.service.ts
Added a private endpoint getter, switched DTO conversions to use this.endpoint, and updated batch skip logic to allow the Buffer upload path when a buffer is present.
Resource upload: data URL → Buffer
apps/api/src/modules/tool/resource.service.ts
uploadDataUrlResource now decodes base64 data URLs into a Buffer and passes that buffer to DriveFile creation instead of passing the raw base64 string.
DTO param rename: origin → endpoint
apps/api/src/modules/drive/drive.dto.ts
Renamed origin parameter to endpoint (optional string) in driveFilePO2DTO, and updated URL construction to use endpoint for content URLs.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Review interplay between the new endpoint getter and places constructing file URLs.
  • Verify batch processing branches correctly select the buffer upload path and that buffer consumption is safe (no double-encoding).
  • Check data-url decoding edge cases (invalid base64, large payloads) and existing error handling.

Possibly related PRs

Suggested reviewers

  • mrcfps
  • CH1111
  • alchemistklk

Poem

🐰 I hopped through code where bytes now play,
Base64 unwrapped to Buffer clay.
Endpoints renamed, the URLs align,
Batch skips step where buffers shine—
A tiny hop, a cleaner day. 🥕

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description lacks the required Summary section with issue details, motivation, and context; it only contains the template without substantive content. Add a comprehensive Summary section that explains the issue being fixed, motivation, context, and any dependencies required for the changes.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main changes: passing decoded buffer to drive service and updating the skip condition, which align with the changeset modifications.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/mashu/base64

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.

…pty resource variables during copilot autogeneration and update sitemap dates.
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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
apps/api/src/modules/drive/drive.service.ts (1)

85-87: Remove the unused origin getter.

The origin getter (lines 85-87) is not referenced anywhere in the codebase and has been superseded by the endpoint getter. Delete it to eliminate dead code.

🧹 Nitpick comments (1)
apps/api/src/modules/drive/drive.dto.ts (1)

13-15: Minor: Update JSDoc description to match parameter name.

The JSDoc description says "Server origin" but the parameter is now named endpoint. Consider updating the description for consistency.

Apply this diff:

 /**
  * Transform DriveFile Prisma model to DriveFile DTO
  * @param driveFile - Prisma DriveFile model
- * @param endpoint - Server origin for generating content URL (e.g., 'https://api.example.com')
+ * @param endpoint - Server endpoint for generating content URL (e.g., 'https://api.example.com')
  */
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 73be825 and 39f3f65.

📒 Files selected for processing (2)
  • apps/api/src/modules/drive/drive.dto.ts (2 hunks)
  • apps/api/src/modules/drive/drive.service.ts (2 hunks)
🧰 Additional context used
📓 Path-based instructions (15)
**/*.{js,ts,jsx,tsx}

📄 CodeRabbit inference engine (.cursorrules)

**/*.{js,ts,jsx,tsx}: Always use optional chaining (?.) when accessing object properties
Always use nullish coalescing (??) or default values for potentially undefined values
Always check array existence before using array methods
Always validate object properties before destructuring
Always use single quotes for string literals in JavaScript/TypeScript code

**/*.{js,ts,jsx,tsx}: Use semicolons at the end of statements
Include spaces around operators (e.g., a + b instead of a+b)
Always use curly braces for control statements
Place opening braces on the same line as their statement

**/*.{js,ts,jsx,tsx}: Group import statements in order: React/framework libraries, third-party libraries, internal modules, relative path imports, type imports, style imports
Sort imports alphabetically within each import group
Leave a blank line between import groups
Extract complex logic into custom hooks
Use functional updates for state (e.g., setCount(prev => prev + 1))
Split complex state into multiple state variables rather than single large objects
Use useReducer for complex state logic instead of multiple useState calls

Files:

  • apps/api/src/modules/drive/drive.dto.ts
  • apps/api/src/modules/drive/drive.service.ts
**/*.{js,ts,tsx,jsx,py,java,cpp,c,cs,rb,go,rs,php,swift,kt,scala,r,m,mm,sql}

📄 CodeRabbit inference engine (.cursor/rules/00-language-priority.mdc)

**/*.{js,ts,tsx,jsx,py,java,cpp,c,cs,rb,go,rs,php,swift,kt,scala,r,m,mm,sql}: All code comments MUST be written in English
All variable names, function names, class names, and other identifiers MUST use English words
Comments should be concise and explain 'why' rather than 'what'
Use proper grammar and punctuation in comments
Keep comments up-to-date when code changes
Document complex logic, edge cases, and important implementation details
Use clear, descriptive names that indicate purpose
Avoid abbreviations unless they are universally understood

Files:

  • apps/api/src/modules/drive/drive.dto.ts
  • apps/api/src/modules/drive/drive.service.ts
**/*.{js,ts,tsx,jsx}

📄 CodeRabbit inference engine (.cursor/rules/00-language-priority.mdc)

Use JSDoc style comments for functions and classes in JavaScript/TypeScript

Files:

  • apps/api/src/modules/drive/drive.dto.ts
  • apps/api/src/modules/drive/drive.service.ts
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/01-code-style.mdc)

**/*.{js,jsx,ts,tsx}: Use single quotes for string literals in TypeScript/JavaScript
Always use optional chaining (?.) when accessing object properties in TypeScript/JavaScript
Always use nullish coalescing (??) or default values for potentially undefined values in TypeScript/JavaScript
Always check array existence before using array methods in TypeScript/JavaScript
Validate object properties before destructuring in TypeScript/JavaScript
Use ES6+ features like arrow functions, destructuring, and spread operators in TypeScript/JavaScript
Avoid magic numbers and strings - use named constants in TypeScript/JavaScript
Use async/await instead of raw promises for asynchronous code in TypeScript/JavaScript

Files:

  • apps/api/src/modules/drive/drive.dto.ts
  • apps/api/src/modules/drive/drive.service.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/03-typescript-guidelines.mdc)

**/*.{ts,tsx}: Avoid using any type whenever possible - use unknown type instead with proper type guards
Always define explicit return types for functions, especially for public APIs
Prefer extending existing types over creating entirely new types
Use TypeScript utility types (Partial<T>, Pick<T, K>, Omit<T, K>, Readonly<T>, Record<K, T>) to derive new types
Use union types and intersection types to combine existing types
Always import types explicitly using the import type syntax
Group type imports separately from value imports
Minimize creating local type aliases for imported types

Files:

  • apps/api/src/modules/drive/drive.dto.ts
  • apps/api/src/modules/drive/drive.service.ts
**/*.{js,ts,jsx,tsx,css,json}

📄 CodeRabbit inference engine (.cursor/rules/04-code-formatting.mdc)

Maximum line length of 100 characters

Files:

  • apps/api/src/modules/drive/drive.dto.ts
  • apps/api/src/modules/drive/drive.service.ts
**/*.{js,ts,jsx,tsx,css,json,yml,yaml}

📄 CodeRabbit inference engine (.cursor/rules/04-code-formatting.mdc)

Use 2 spaces for indentation, no tabs

Files:

  • apps/api/src/modules/drive/drive.dto.ts
  • apps/api/src/modules/drive/drive.service.ts
**/*.{js,ts,jsx,tsx,css,json,yml,yaml,md}

📄 CodeRabbit inference engine (.cursor/rules/04-code-formatting.mdc)

No trailing whitespace at the end of lines

Files:

  • apps/api/src/modules/drive/drive.dto.ts
  • apps/api/src/modules/drive/drive.service.ts
**/*.{css,scss,sass,less,js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/09-design-system.mdc)

**/*.{css,scss,sass,less,js,jsx,ts,tsx}: Primary color (#155EEF) should be used for main brand color in buttons, links, and accents
Error color (#F04438) should be used for error states and destructive actions
Success color (#12B76A) should be used for success states and confirmations
Warning color (#F79009) should be used for warnings and important notifications
Info color (#0BA5EC) should be used for informational elements

Files:

  • apps/api/src/modules/drive/drive.dto.ts
  • apps/api/src/modules/drive/drive.service.ts
**/*.{tsx,ts}

📄 CodeRabbit inference engine (.cursor/rules/09-i18n-guidelines.mdc)

**/*.{tsx,ts}: Use the translation wrapper component and useTranslation hook in components
Ensure all user-facing text is translatable

Files:

  • apps/api/src/modules/drive/drive.dto.ts
  • apps/api/src/modules/drive/drive.service.ts
**/*.{tsx,ts,json}

📄 CodeRabbit inference engine (.cursor/rules/09-i18n-guidelines.mdc)

Support dynamic content with placeholders in translations

Files:

  • apps/api/src/modules/drive/drive.dto.ts
  • apps/api/src/modules/drive/drive.service.ts
**/*.{tsx,ts,jsx,js,vue,css,scss,less}

📄 CodeRabbit inference engine (.cursor/rules/11-ui-design-patterns.mdc)

**/*.{tsx,ts,jsx,js,vue,css,scss,less}: Use the primary blue (#155EEF) for main UI elements, CTAs, and active states
Use red (#F04438) only for errors, warnings, and destructive actions
Use green (#12B76A) for success states and confirmations
Use orange (#F79009) for warning states and important notifications
Use blue (#0BA5EC) for informational elements
Primary buttons should be solid with the primary color
Secondary buttons should have a border with transparent or light background
Danger buttons should use the error color
Use consistent padding, border radius, and hover states for all buttons
Follow fixed button sizes based on their importance and context
Use consistent border radius (rounded-lg) for all cards
Apply light shadows (shadow-sm) for card elevation
Maintain consistent padding inside cards (p-4 or p-6)
Use subtle borders for card separation
Ensure proper spacing between card elements
Apply consistent styling to all form inputs
Use clear visual indicators for focus, hover, and error states in form elements
Apply proper spacing between elements using 8px, 16px, 24px increments
Ensure proper alignment of elements (left, center, or right)
Use responsive layouts that work across different device sizes
Maintain a minimum contrast ratio of 4.5:1 for text

Files:

  • apps/api/src/modules/drive/drive.dto.ts
  • apps/api/src/modules/drive/drive.service.ts
**/*.{tsx,ts,jsx,js,vue}

📄 CodeRabbit inference engine (.cursor/rules/11-ui-design-patterns.mdc)

**/*.{tsx,ts,jsx,js,vue}: Include appropriate loading states for async actions in buttons
Group related form elements with appropriate spacing
Provide clear validation feedback for forms
Ensure proper labeling and accessibility for form elements
Ensure all interactive elements are keyboard accessible
Include appropriate ARIA attributes for complex components
Provide alternative text for images and icons
Support screen readers with semantic HTML elements

Files:

  • apps/api/src/modules/drive/drive.dto.ts
  • apps/api/src/modules/drive/drive.service.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursor/rules/08-contributing-guidelines.mdc)

**/*.{ts,tsx,js,jsx}: Follow the TypeScript/JavaScript style guidelines
Ensure code is well-tested and documented

Files:

  • apps/api/src/modules/drive/drive.dto.ts
  • apps/api/src/modules/drive/drive.service.ts
apps/api/src/**/*.{controller,service}.ts

📄 CodeRabbit inference engine (.cursor/rules/06-api-structure.mdc)

Implement proper error handling in API modules

Files:

  • apps/api/src/modules/drive/drive.service.ts
🧬 Code graph analysis (2)
apps/api/src/modules/drive/drive.dto.ts (4)
apps/api/src/modules/drive/drive.service.ts (1)
  • endpoint (89-91)
packages/request/src/requests/types.gen.ts (1)
  • DriveFile (7554-7623)
packages/ai-workspace-common/src/requests/types.gen.ts (1)
  • DriveFile (7554-7623)
packages/openapi-schema/src/types.gen.ts (1)
  • DriveFile (7554-7623)
apps/api/src/modules/drive/drive.service.ts (3)
packages/request/src/requests/types.gen.ts (1)
  • DriveFile (7554-7623)
packages/openapi-schema/src/types.gen.ts (1)
  • DriveFile (7554-7623)
apps/api/src/modules/drive/drive.dto.ts (1)
  • driveFilePO2DTO (15-37)
⏰ 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). (1)
  • GitHub Check: build / Build
🔇 Additional comments (4)
apps/api/src/modules/drive/drive.dto.ts (1)

35-35: LGTM! Parameter rename improves clarity.

The URL construction correctly uses the renamed endpoint parameter, maintaining the same functionality while improving code clarity.

apps/api/src/modules/drive/drive.service.ts (3)

89-91: LGTM! Consistent implementation with existing pattern.

The new endpoint getter follows the same pattern as the existing origin getter and correctly retrieves the endpoint configuration.


96-98: LGTM! Correctly uses the new endpoint parameter.

The toDTO method now uses this.endpoint instead of this.origin, correctly aligning with the parameter rename in driveFilePO2DTO.


328-331: LGTM! Skip condition correctly includes buffer check.

The updated skip condition now properly enables the buffer upload path (Case 0, lines 351-354) when a buffer is provided, aligning with the PR's objective to support decoded buffer uploads.

@lefarcen lefarcen merged commit d357159 into main Dec 10, 2025
2 checks passed
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.

3 participants