Skip to content

fix(documents): strip extension from document name on upload and rename - #1361

Open
Pallavikumarimdb wants to merge 1 commit into
papra-hq:mainfrom
Pallavikumarimdb:fix/document-upload-filename-extension
Open

fix(documents): strip extension from document name on upload and rename#1361
Pallavikumarimdb wants to merge 1 commit into
papra-hq:mainfrom
Pallavikumarimdb:fix/document-upload-filename-extension

Conversation

@Pallavikumarimdb

Copy link
Copy Markdown
Contributor

Description

This PR resolves the issue where documents uploaded via the web UI permanently keep their file extensions in their display names and cannot have them removed.

Changes

  • Shared Files Helper: Updated getFileNameWithoutExtension in file-names.ts to return the extension-stripped filename string directly rather than a wrapped object.
  • Document Upload (Server):
    • Updated createDocument and restoreDocument inside documents.usecases.ts to use getFileNameWithoutExtension to save default document names without extensions.
    • Modified restoreDocument in documents.repository.ts to handle originalName and name separately so that the original extension remains preserved in the storage metadata.
  • Document Rename (Client):
    • Removed extension-appending logic from the document rename onSubmit handler in rename-document-button.component.tsx, allowing users to rename their documents without forcing the original file extension.
  • Tests:
    • Updated expected document names in unit tests in documents.usecases.test.ts and integration/e2e tests in upload-documents.e2e.test.ts.

Closes: #1169

@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Document names are now stored and edited without file extensions, while originalName retains the full filename. Filename normalization, restore behavior, upload expectations, and the client rename dialog are updated accordingly.

Changes

Document naming

Layer / File(s) Summary
Filename normalization
apps/papra-server/src/modules/shared/files/file-names.ts
getFileNameWithoutExtension returns a string directly and handles extensionless and leading-dot filenames.
Server document persistence
apps/papra-server/src/modules/documents/documents.repository.ts, apps/papra-server/src/modules/documents/documents.usecases.ts, apps/papra-server/src/modules/documents/*.test.ts, apps/papra-server/src/modules/documents/e2e/*
Created and restored documents persist extensionless name values, while originalName remains independent and retains the full filename. Tests update the corresponding unit and E2E expectations.
Client rename submission
apps/papra-client/src/modules/documents/components/rename-document-button.component.tsx
The rename dialog submits the entered name without reattaching the original extension.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

Suggested reviewers: corentinth

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The changes address #1169 by removing extension display names on upload/restore and allowing rename without reattaching extensions.
Out of Scope Changes check ✅ Passed All code changes are directly tied to document name extension handling and corresponding tests.
Title check ✅ Passed The title clearly describes the main change: removing file extensions from document names during upload and rename.
Description check ✅ Passed The description accurately explains the document naming changes, affected components, metadata handling, and test updates.

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.

@Pallavikumarimdb
Pallavikumarimdb marked this pull request as ready for review July 18, 2026 20:27
@Pallavikumarimdb
Pallavikumarimdb requested a review from a team as a code owner July 18, 2026 20:27

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

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

⚠️ Outside diff range comments (1)
apps/papra-client/src/modules/documents/components/rename-document-button.component.tsx (1)

50-59: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Use props.documentName as the form value. getDocumentNameWithoutExtension will strip any user-entered trailing segment, so names like Q3.Report reopen as Q3. Apply this in both initialValues and the createEffect reset.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@apps/papra-client/src/modules/documents/components/rename-document-button.component.tsx`
around lines 50 - 59, Update the rename form initialization and reset in the
component’s form setup and createEffect to use props.documentName directly as
the name value. Remove getDocumentNameWithoutExtension from both initialValues
and the reactive reset so names containing trailing segments such as “Q3.Report”
are preserved.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@apps/papra-client/src/modules/documents/components/rename-document-button.component.tsx`:
- Line 12: Remove the unused getDocumentNameWithoutExtension import from
rename-document-button.component.tsx, ensuring form initialization no longer
references it.

---

Outside diff comments:
In
`@apps/papra-client/src/modules/documents/components/rename-document-button.component.tsx`:
- Around line 50-59: Update the rename form initialization and reset in the
component’s form setup and createEffect to use props.documentName directly as
the name value. Remove getDocumentNameWithoutExtension from both initialValues
and the reactive reset so names containing trailing segments such as “Q3.Report”
are preserved.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: ab27e721-1d07-41ad-ac42-a45917d94da4

📥 Commits

Reviewing files that changed from the base of the PR and between b6c060d and 22b704b.

📒 Files selected for processing (6)
  • apps/papra-client/src/modules/documents/components/rename-document-button.component.tsx
  • apps/papra-server/src/modules/documents/documents.repository.ts
  • apps/papra-server/src/modules/documents/documents.usecases.test.ts
  • apps/papra-server/src/modules/documents/documents.usecases.ts
  • apps/papra-server/src/modules/documents/e2e/upload-documents.e2e.test.ts
  • apps/papra-server/src/modules/shared/files/file-names.ts

import { createToast } from '@/modules/ui/components/sonner';
import { TextField, TextFieldLabel, TextFieldRoot } from '@/modules/ui/components/textfield';
import { getDocumentNameExtension, getDocumentNameWithoutExtension } from '../document.models';
import { getDocumentNameWithoutExtension } from '../document.models';

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Remove the unused import.

Since getDocumentNameWithoutExtension should no longer be used for form initialization (to avoid truncating user-provided names containing dots), this import can be completely removed.

♻️ Proposed fix
-import { getDocumentNameWithoutExtension } from '../document.models';
📝 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.

Suggested change
import { getDocumentNameWithoutExtension } from '../document.models';
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@apps/papra-client/src/modules/documents/components/rename-document-button.component.tsx`
at line 12, Remove the unused getDocumentNameWithoutExtension import from
rename-document-button.component.tsx, ensuring form initialization no longer
references it.

@cla-signer

cla-signer Bot commented Aug 18, 2026

Copy link
Copy Markdown

Contributor License Agreement

✅ Everyone who contributed to this pull request has signed the CLA for it.

@cla-signer cla-signer Bot added the cla: signed CLA have been signed for this contribution label Aug 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla: signed CLA have been signed for this contribution

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Documents uploaded through web UI permanently have extension in name

1 participant