Ordinary JSON is silently discarded when it mentions notebook format markers

Đang mở
#2,804 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

@CHX606 đang làm issue này rồi.

Từ ngày 1/11/2026.

  • #2805 của @CHX606 — đang mở
  • #2810 của @rtynbirf — đang mở
  • #2811 của @sunhouy — đang mở
  • #2813 của @phanipaladugula — đang mở

Đánh giá

Độ khó
3/5
Thời gian dự kiến
Nửa ngày
Mức phù hợp với người mới
25/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ệ
jupyter-notebook, python
Lĩnh vực
tooling

Hướng nghiên cứu

Start in IpynbConverter.accepts(), which currently matches the nbformat and nbformat_minor substrings in the decoded text, and in _convert(), which treats a missing top-level cells as an empty list. Done means ordinary JSON that only mentions those markers is preserved as text, while genuine notebooks still convert with and without a UTF-8 BOM and the stream position is kept. Pull request #2805 already targets this, so check it before starting.

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

Mô tả

Ordinary JSON is silently converted to empty Markdown when it mentions both nbformat and nbformat_minor, even when those words occur only inside a string value or a nested example.

IpynbConverter.accepts() currently checks for those substrings in the decoded text. Once it accepts the input, _convert() reads a missing top-level cells as an empty list and returns an empty successful conversion, so the plain-text converter never preserves the original JSON.

Reproduction with MarkItDown 0.1.9 on main at 7482c092d9c0074a89803c9fdb63a969e7fe17fc, Windows 11 / Python 3.12:

import io
import json
from markitdown import MarkItDown, StreamInfo

payload = {
    "description": "The format uses nbformat and nbformat_minor fields.",
    "items": ["important content"],
}
content = json.dumps(payload)
result = MarkItDown().convert_stream(
    io.BytesIO(content.encode("utf-8")),
    stream_info=StreamInfo(
        extension=".json", mimetype="application/json", charset="utf-8"
    ),
)
print(repr(result.markdown))

Actual output: ''.

Expected: the JSON text is preserved, as for other ordinary JSON documents.

This also reproduces with {"nbformat": 4, "nbformat_minor": 5, "data": ["important content"]} and with a notebook-shaped object nested under an example key.

A focused fix can decode the candidate JSON and require the notebook markers and a cells list at the top level. It should preserve .ipynb extension routing, genuine MIME-detected notebooks (including a UTF-8 BOM), and the stream position. Malformed or excessively nested JSON should be declined rather than crash detection.

Local regression results on the untouched implementation: 4 failed, 2 passed. The failing cases cover the three ordinary-JSON examples and rejection of a deeply nested non-notebook value. The two controls confirm genuine notebooks still convert with and without a BOM.

AI assistance: Codex identified the issue, executed the reproduction and regression tests, and prepared this report on behalf of the account owner.

Ngôn ngữ chính
Python
Star
194k
Fork
14.5k
Merge trung bình
22 phút
Pull request đã merge (30 ngày)
5

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

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

  • Có Dockerfile hoặc tệp Docker Compose
  • Không có mẫu pull request
  • Không có hướng dẫn đóng góp

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 microsoft/markitdown

Tất cả issue của microsoft/markitdown

Issue tương tự

Thêm issue về Python

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.