Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Sep 2, 2025

This PR fixes the error that occurs when paperless-gpt tries to create correspondents automatically. The issue was caused by sending an invalid matching_algorithm value to the paperless-ngx API.

Problem

When updating documents with suggested correspondents, users encountered this error:

Error creating correspondent: 400, {"matching_algorithm":["\"0\" is not a valid choice."]}

Root Cause

The instantiateCorrespondent function was setting MatchingAlgorithm: 0, but the paperless-ngx API only accepts specific values:

  • 1: Auto (default matching)
  • 2: Fuzzy matching
  • 3: Regular expression
  • 4: Exact match

Solution

Changed the MatchingAlgorithm field from 0 to 1 (Auto matching) in the instantiateCorrespondent function. This is a minimal, one-line fix that ensures compatibility with the paperless-ngx API while using the most appropriate default matching algorithm for automatically generated correspondents.

Testing

  • Added comprehensive tests to verify the fix works correctly
  • Validated that the JSON sent to paperless-ngx now contains "matching_algorithm": 1
  • Confirmed existing functionality remains intact

Fixes #609.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • openaipublic.blob.core.windows.net
    • Triggering command: /tmp/go-build3221326226/b001/paperless-gpt.test -test.testlogfile=/tmp/go-build3221326226/b001/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copy link
Contributor Author

Copilot AI commented Sep 2, 2025

@icereed 👋 This repository doesn't have Copilot instructions. With Copilot instructions, I can understand the repository better, work faster and produce higher quality PRs.

I can generate a .github/copilot-instructions.md file for you automatically. Click here to open a pre-filled issue and assign it to me. I'll write the instructions, and then tag you for review.

@Copilot Copilot AI changed the title [WIP] Error updating documents Fix correspondent creation error by setting valid matching_algorithm value Sep 2, 2025
@Copilot Copilot AI requested a review from icereed September 2, 2025 11:22
Copilot finished work on behalf of icereed September 2, 2025 11:22
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.

Error updating documents

2 participants