Skip to content

JabKit BibTeX conversion silently drops string definitions and preambles, including in-place conversion #17409

Open

Description

@doraem-on

Description

I found that JabKit's BibTeX-to-BibTeX conversion silently drops @String definitions and @Preamble content while leaving references to the deleted strings in the entries. The command returns exit code 0 with no warning.

This also happens when I use the same file as input and output: the conversion succeeds, but the original library loses its string definitions and preamble. I reproduced the problem in both the native executable and the portable Java distribution, so it is not limited to native-image packaging.

JabRef version

Latest development build: 6.0-beta.142--2026-10-07--7415e00.

Commit: 7415e005af647578025413da8dded1e6cd8f6657.

Operating system

macOS 26.5.2, ARM64. I tested the official native macOS-silicon build and the official portable macOS-silicon distribution using its bundled Amazon Corretto 25.0.4.1 Java runtime.

Observed behavior

My disposable input fixture contains:

@String{journalname = {Journal of Reproducible Tests}}
@Preamble{"\newcommand{\noop}[1]{}"}

@Article{Smith2024,
  author = {Smith, Alice},
  title = {Reproducible Conversion Test},
  journal = journalname,
  year = {2024},
}

I converted this using jabkit convert --porcelain --input input.bib --input-format bibtex --output-format bibtex --output converted.bib.

The command returned success, but the generated file contained only the article. Both the @String declaration and the @Preamble were missing, while journal = journalname remained in the article without its definition.

I also tested stdout output and conversion with the same input/output path, using separate disposable copies. All three paths reproduced the loss in both distributions: six conversion cases, all returning exit code 0 without a warning.

Effect on bibliography data

I checked the effect by exporting the original fixture and the converted bibliography to RIS using the portable Java distribution.

Exporting the original produced:

JO  - Journal of Reproducible Tests

Exporting the converted bibliography produced:

JO  - #journalname#

Both RIS exports returned exit code 0. This shows that the conversion loses the journal's resolved value; it is not merely a formatting change.

Expected behavior

BibTeX-to-BibTeX conversion should preserve the string definitions referenced by its entries and the library preamble. A successful conversion should not leave unresolved string references or silently discard library content, especially when replacing the input file.

Possible cause

In ExportService.createBibtexExporter(), the export method receives the original BibDatabaseContext but writes a new context built from new BibDatabase(entries). This retains the entries while discarding the original database's string definitions and preamble before the writer can serialize them.

Source:

private Exporter createBibtexExporter() {
return new Exporter("bibtex", "BibTex", StandardFileType.BIBTEX_DB) {
@Override
public void export(BibDatabaseContext databaseContext, Path file, List<BibEntry> entries) throws IOException {
internalSaveDatabaseContext(new BibDatabaseContext(new BibDatabase(entries)), file);
}

Validation

These results came from actual executions of the downloaded binaries, with captured exit codes and output. I used disposable fixtures, kept the original reference fixture unchanged, and did not modify an existing user bibliography. I searched existing issues and pull requests and did not find an exact report for this conversion path.

Captured test output

I captured each process's exit code, stdout, and stderr, along with the contents of the generated file. These were CLI regression checks against the actual downloaded binaries, not mocked executions or a JUnit/Gradle suite.

The following records are extracted from my saved execution log. portable refers to the portable distribution's bundled Java runtime, and inplace means that the input and output arguments pointed to the same disposable file.

[
  {"build": "native", "case": "file", "exit_code": 0, "stderr": ""},
  {"build": "native", "case": "stdout", "exit_code": 0, "stderr": ""},
  {"build": "native", "case": "inplace", "exit_code": 0, "stderr": ""},
  {"build": "portable", "case": "file", "exit_code": 0, "stderr": ""},
  {"build": "portable", "case": "stdout", "exit_code": 0, "stderr": ""},
  {"build": "portable", "case": "inplace", "exit_code": 0, "stderr": ""}
]

All six cases produced exactly the following BibTeX. For the stdout cases this is the captured stdout; for the file and in-place cases this is the complete resulting file content:

@Article{Smith2024,
  author = {Smith, Alice},
  title = {Reproducible Conversion Test},
  journal = journalname,
  year = {2024},
}

There is no @String declaration or @Preamble in that output, but the unresolved journalname reference remains. The file and in-place cases had empty stdout as well as empty stderr.

For the downstream comparison, the original fixture produced this complete RIS output through the portable Java build:

TY  - JOUR
AU  - Smith, Alice
T1  - Reproducible Conversion Test
JO  - Journal of Reproducible Tests
Y1  - 2024
ER  -

The BibTeX-converted fixture produced this complete RIS output through that same Java build:

TY  - JOUR
AU  - Smith, Alice
T1  - Reproducible Conversion Test
JO  - #journalname#
Y1  - 2024
ER  -

Both RIS commands returned exit code 0, with empty stdout and stderr because the results were written to files. The unchanged original fixture's SHA-256 was fbe0220ce53e3347754ffcfc1f9b4454b1b00a4f8aa42efc10c9e0fba833ccdf.

Activity

  1. doraem-on commented on Oct 8, 2026

    @doraem-on
    ContributorAuthor

    /assign-me

  2. jabref-machine commented on Oct 8, 2026

    @jabref-machine
    Collaborator

    ⚠️ Self-Assignment Not Allowed

    Hi @doraem-on, you cannot self-assign an issue you created.

    Note

    This project requires maintainer approval before working on self-created issues to ensure alignment with the project roadmap.

    What you can do
    • Wait for a maintainer to review and approve your issue
    • Ask a maintainer to assign you if the issue is approved
    • Look for other existing issues to contribute to
  3. doraem-on commented on Oct 8, 2026

    @doraem-on
    ContributorAuthor

    kindly confirm this issue , Id like to work on it

  4. added
    📍 AssignedAssigned by assign-issue-action (or manually assigned)
    on Oct 8, 2026
  5. github-actions commented on Oct 9, 2026

    @github-actions
    Contributor

    A pull request addressing the issue has been created. You can try out the pull request by following the steps at How to try out any JabRef pull request?.

    For any feedback, add a comment to the pull request at #17417.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

📌 Pinned📍 AssignedAssigned by assign-issue-action (or manually assigned)

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions