forked from nloui/paperless-mcp
-
Notifications
You must be signed in to change notification settings - Fork 29
Fix bulk custom field parameters #89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
baruchiro
merged 5 commits into
baruchiro:main
from
peshay:fix-bulk-custom-field-params
May 18, 2026
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
df2d977
Fix bulk custom field parameters
peshay 7a0f5f5
Address bulk custom field review feedback
peshay 8e89299
Add changeset for custom field bulk edit fix
peshay 19cd9ad
Address review feedback for bulk custom fields
91e5cd8
Merge branch 'main' into fix-bulk-custom-field-params
baruchiro File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@baruchiro/paperless-mcp": patch | ||
| --- | ||
|
|
||
| Fix bulk document custom field edits to send Paperless-NGX compatible `add_custom_fields` parameters and preserve intentionally empty custom field values. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| import assert from "node:assert/strict"; | ||
| import { test } from "node:test"; | ||
| import { buildBulkEditParameters } from "./documents"; | ||
|
|
||
| test("buildBulkEditParameters sends Paperless bulk custom fields as id:value map", () => { | ||
| const parameters = buildBulkEditParameters( | ||
| { remove_custom_fields: [] }, | ||
| [ | ||
| { field: 9, value: "" }, | ||
| { field: 10, value: "2026-05-14" }, | ||
| ] | ||
| ); | ||
|
|
||
| assert.deepEqual(parameters, { | ||
| remove_custom_fields: [], | ||
| add_custom_fields: { | ||
| "9": "", | ||
| "10": "2026-05-14", | ||
| }, | ||
| }); | ||
| assert.ok(!("assign_custom_fields" in parameters)); | ||
| assert.ok(!("assign_custom_fields_values" in parameters)); | ||
| }); | ||
|
|
||
| test("buildBulkEditParameters preserves null custom field values", () => { | ||
| const parameters = buildBulkEditParameters({}, [{ field: 9, value: null }]); | ||
|
|
||
| assert.deepEqual(parameters, { | ||
| add_custom_fields: { | ||
| "9": null, | ||
| }, | ||
| }); | ||
| }); | ||
|
|
||
| test("buildBulkEditParameters includes Paperless-required empty custom field keys", () => { | ||
| const parameters = buildBulkEditParameters({}, undefined, true); | ||
|
|
||
| assert.deepEqual(parameters, { | ||
| add_custom_fields: {}, | ||
| remove_custom_fields: [], | ||
| }); | ||
| }); | ||
|
|
||
| test("buildBulkEditParameters preserves an empty custom fields array", () => { | ||
| const parameters = buildBulkEditParameters({}, []); | ||
|
|
||
| assert.deepEqual(parameters, { | ||
| add_custom_fields: {}, | ||
| }); | ||
| assert.ok(!("remove_custom_fields" in parameters)); | ||
| }); | ||
|
|
||
| test("buildBulkEditParameters preserves an empty custom fields array with defaults", () => { | ||
| const parameters = buildBulkEditParameters({}, [], true); | ||
|
|
||
| assert.deepEqual(parameters, { | ||
| add_custom_fields: {}, | ||
| remove_custom_fields: [], | ||
| }); | ||
| }); | ||
|
|
||
| test("buildBulkEditParameters combines base parameters with custom fields", () => { | ||
| const parameters = buildBulkEditParameters( | ||
| { add_tags: [3], remove_tags: [1, 2] }, | ||
| [{ field: 9, value: "pending" }] | ||
| ); | ||
|
|
||
| assert.deepEqual(parameters, { | ||
| add_tags: [3], | ||
| remove_tags: [1, 2], | ||
| add_custom_fields: { | ||
| "9": "pending", | ||
| }, | ||
| }); | ||
| }); | ||
|
|
||
| test("buildBulkEditParameters preserves supported custom field value types", () => { | ||
| const parameters = buildBulkEditParameters({}, [ | ||
| { field: 1, value: 42 }, | ||
| { field: 2, value: true }, | ||
| { field: 3, value: "" }, | ||
| { field: 4, value: null }, | ||
| { field: 5, value: [123, 456] }, | ||
| ]); | ||
|
|
||
| assert.deepEqual(parameters.add_custom_fields, { | ||
| "1": 42, | ||
| "2": true, | ||
| "3": "", | ||
| "4": null, | ||
| "5": [123, 456], | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.