Skip to content

Conversation

@tomolopolis
Copy link
Member

@tomolopolis tomolopolis commented Nov 13, 2025

Fixes meta-annotation upload bug, where if meta annotations are exported (or generated) in an export, and uploaded to a trainer instance they wouldn't appear.

ALSO - added a test for this API, and added to GHA jobs. The start of having the backend unit tested...


Note

Fixes meta-annotation import bug and adds Django backend unit tests with CI/CD integration.

  • Backend API:
    • Fix meta-annotation import in api/data_utils.py: set meta_task correctly, persist acc, and link meta_task_value.
    • Add InvalidParameterError and raise when no cdb/vocab/modelpack provided.
    • Improve error logging/messages in api/views.py for uploads.
  • Tests:
    • Add unit tests for upload_projects_export in api/tests/test_data_utils.py with fixture fixtures/example.json; cover CDB/Vocab, ModelPack, members, validated docs, custom suffix, empty projects, missing params, and unknown users.
    • Remove empty api/tests.py placeholder.
  • CI/CD:
    • Add test-backend job (Python 3.11, spaCy model) to CI, QA, and release workflows; gate builds on it.
    • Run Django tests in container builds; push Docker images in QA/release.
    • Minor YAML normalization (consistent quoting).

Written by Cursor Bugbot for commit 08f9752. This will update automatically on new commits. Configure here.

@tomolopolis
Copy link
Member Author

logger.error(f"Failed to upload projects export: {str(e)}", exc_info=e)
return Response(f"Failed to upload projects export: {e.message}", 500)
logger.error(f"Failed to upload projects export: {e}", exc_info=e)
return Response(f"Failed to upload projects export: {e}", 500)

Check warning

Code scanning / CodeQL

Information exposure through an exception Medium

Stack trace information
flows to this location and may be exposed to an external user.

Copilot Autofix

AI 19 days ago

To fix the issue, do not include the exception message or stack trace in HTTP responses sent to users. Instead, return a generic error message to the user, while ensuring that the exception details are fully logged server-side for debugging.

Steps:

  • In the except Exception as e: block in upload_deployment, change the return value from Response(f"Failed to upload projects export: {e}", 500) to something generic, e.g. Response("Failed to upload projects export.", 500), omitting variable data.
  • No new methods or imports are required, as logging is already handled above the return statement with the logger.

Only medcat-trainer/webapp/api/api/views.py, lines 709-711, need changing.


Suggested changeset 1
medcat-trainer/webapp/api/api/views.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/medcat-trainer/webapp/api/api/views.py b/medcat-trainer/webapp/api/api/views.py
--- a/medcat-trainer/webapp/api/api/views.py
+++ b/medcat-trainer/webapp/api/api/views.py
@@ -708,7 +708,7 @@
         return Response("successfully uploaded", 200)
     except Exception as e:
         logger.error(f"Failed to upload projects export: {e}", exc_info=e)
-        return Response(f"Failed to upload projects export: {e}", 500)
+        return Response("Failed to upload projects export.", 500)
 
 
 @api_view(http_method_names=['GET', 'DELETE'])
EOF
@@ -708,7 +708,7 @@
return Response("successfully uploaded", 200)
except Exception as e:
logger.error(f"Failed to upload projects export: {e}", exc_info=e)
return Response(f"Failed to upload projects export: {e}", 500)
return Response("Failed to upload projects export.", 500)


@api_view(http_method_names=['GET', 'DELETE'])
Copilot is powered by AI and may make mistakes. Always verify output.
@tomolopolis tomolopolis committed this autofix suggestion 19 days ago.
@tomolopolis tomolopolis force-pushed the fix-meta-anno-export-upload branch from 937fb32 to 08f9752 Compare November 14, 2025 15:49
@tomolopolis tomolopolis merged commit 6c75531 into main Nov 14, 2025
11 checks passed
@tomolopolis tomolopolis deleted the fix-meta-anno-export-upload branch November 14, 2025 18:26
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.

2 participants