fix: support versioned select option schemas#15
Merged
Conversation
Paperless-ngx v2.14+ requires each entry in extra_data.select_options
to be a JSON object with a 'label' key. Serialising as bare strings
(List<string>) triggers "'str' object has no attribute 'get'" in
paperless's serialisers.py, surfaced through this MCP as
UPSTREAM_ERROR / HTTP 400.
Introduce a SelectOption record with a Label property that serialises
to {"label": "..."}. Change CustomFieldExtraData.SelectOptions
from List<string> to List<SelectOption>. Update both call sites in
CustomFieldTools.cs (Create + Update) to wrap the split values.
Verified against paperless-ngx v2.20.15: creating a select field with
23 options now returns 200; without the fix it returned 400.
Keep stable option IDs during updates to avoid clearing assigned values. Serialize the pre-2.14 string shape when required and accept both response formats.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The bug
paperless_custom_fields_createandpaperless_custom_fields_updatefail withUPSTREAM_ERROR/ HTTP 400 when sending bare-string select options topaperless-ngx v2.14 or later. Paperless returns:
{"select_options": ["'str' object has no attribute 'get'"]}Root cause
The select-option wire format changed in paperless-ngx v2.14:
extra_data.select_optionsis a list of strings.labeland anoptional stable
id.The MCP previously modeled every option as a string, so modern Paperless
attempted to call
.get()on a string and rejected the request.The fix
SelectOptionrecords containingidandlabel.them to objects for MCP clients.
api/status/and serialize requestoptions as strings before v2.14 or objects on v2.14 and later.
unchanged options as removed and clear assigned document values.
create, modern ID-preserving update, and legacy update.
Verification
dotnet build -c Release --no-restore: 0 errors, 0 warnings.Backward compatibility
Both Paperless wire formats are supported. Pre-v2.14 servers continue receiving
string lists, while v2.14+ servers receive object lists. Modern option IDs are
returned to MCP clients and retained across updates.