Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

POST /api/collections returns 500 instead of 400 for ADM validation failures

Đang mở Phù hợp với người mới
#505 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
86/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
javascript
Lĩnh vực
api, backend

Hướng nghiên cứu

Bắt đầu tại collections-controller.js:create() và kiểm tra cách các lỗi validation của BaseService.create() được xử lý, sử dụng bước tái hiện với POST /api/collections làm điểm vào. Giữ nguyên chi tiết validation có cấu trúc của 400 và xác minh rằng x_mitre_domains không được hỗ trợ và x_mitre_contents rỗng trả về 400 mà không persistence.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Description

Invalid collection payloads return a generic HTTP 500 instead of a validation response identifying the rejected fields.

Observed on REST API 4.24.0, commit 69b37fe769e6abe7675d413451a8361aecc36bea.

Reproduction
  1. Prepare a valid x-mitre-collection payload containing at least one existing object revision in x_mitre_contents.
  2. Add "x_mitre_domains": ["enterprise-attack"] to its stix object.
  3. POST the payload to /api/collections.

Actual: HTTP 500:

Unable to create collection. Server error.

Expected: HTTP 400 with structured ADM validation details indicating that x_mitre_domains is an unrecognized collection field.

Removing x_mitre_domains allows the nonempty collection to return 201 and persist successfully. Explicitly empty x_mitre_contents also produces the same misleading 500.

Cause and suggested fix

BaseService.create() throws ValidationError, but collections-controller.js:create() maps every exception except DuplicateIdError to a generic 500. The log contains:

Failed with error: ValidationError: ADM validation failed

Preserve the normal validation-error handling and field-level details. Add regressions asserting 400 and no persistence for unsupported fields and empty contents.

These requests did not crash the REST process; REST and MongoDB remained healthy during verification.

Ngôn ngữ chính
JavaScript
Star
56
Fork
18
Merge trung bình
21 giờ 14 phút
Pull request đã merge (30 ngày)
10

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của mitre-attack/attack-workbench-rest-api

Tất cả issue của mitre-attack/attack-workbench-rest-api

Issue tương tự

Thêm issue về JavaScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.