Skip to content

Fix Hayagriva export to nest identifiers under serial-number#15750

Merged
Siedlerchr merged 11 commits into
JabRef:mainfrom
mollyytran:fix-for-issue-15713
May 19, 2026
Merged

Fix Hayagriva export to nest identifiers under serial-number#15750
Siedlerchr merged 11 commits into
JabRef:mainfrom
mollyytran:fix-for-issue-15713

Conversation

@mollyytran

Copy link
Copy Markdown
Contributor

Related issues and pull requests

Closes #15713

PR Description

Fixes #15713

The Hayagriva YAML exporter was writing DOI, ISBN, and ISSN as top-level entry fields. Per the Hayagriva file format spec, these
identifiers should be nested under serial-number. Updated the Hayagriva layout template to conditionally emit a serial-number block and nest identifiers beneath it. Added unit tests for each identifier type.

Steps to test

  1. Open JabRef
  2. Create a new example library
  3. Add an 'article' entry with:
    Author: John Smith
    Title: Sample Title
    DOI: 10.1109/EDOC.2018.00030
  4. File -> Export -> Export as Hayagriva (.yml)
  5. Open the exported file and confirm the output looks like:
      _:
        type: article
        title: "Sample Title"
        author:
          - Smith, John
        serial-number:
          doi: "10.1109/EDOC.2018.00030"
  6. Repeat with ISBN and ISSN entries to verify they also nest under serial-number. Note: ISBN only exists for 'book' entry type.
  7. Screenshots:
Doi-1 Doi-2 Doi-3 Issn-1 Issn-2 Issn-3 Isbn-1 Isbn-2 Isbn-3

AI usage

Claude Code (model claude-opus-4.6)

Checklist

  • I own the copyright of the code submitted and I license it under the MIT license
  • If AI tools were used, I disclosed them in the "AI usage" section and reviewed, understood, and take full ownership of all AI-generated code
  • I manually tested my changes in running JabRef (always required)
  • I added JUnit tests for changes (if applicable)
  • I added screenshots in the PR description (if change is visible to the user)
  • I added a screenshot in the PR description showing a library with a single entry with me as author and as title the issue number
  • I described the change in CHANGELOG.md in a way that can be understood by the average user (if change is visible to the user)
  • I checked the user documentation for up to dateness and submitted a pull request to our user documentation repository

@github-actions github-actions Bot added the status: changes-required Pull requests that are not yet complete label May 17, 2026
@qodo-free-for-open-source-projects

Copy link
Copy Markdown
Contributor

Review Summary by Qodo

Fix Hayagriva export to nest identifiers under serial-number

🐞 Bug fix 🧪 Tests

Grey Divider

Walkthroughs

Description
• Fixed Hayagriva YAML exporter to nest identifiers under serial-number
• DOI, ISBN, and ISSN now correctly nested per Hayagriva spec
• Added three unit tests for each identifier type
• Updated layout template with conditional serial-number block
Diagram
flowchart LR
  A["Hayagriva Layout Template"] -->|"Conditional serial-number block"| B["DOI/ISBN/ISSN Nesting"]
  C["Unit Tests"] -->|"Validates export format"| B
  B -->|"Correct YAML structure"| D["Hayagriva Compliance"]
Loading

Grey Divider

File Changes

1. jablib/src/main/resources/resource/layout/hayagrivayaml.layout 🐞 Bug fix +6/-4

Nest identifiers under serial-number block

• Replaced individual top-level DOI, ISBN, ISSN fields with nested structure
• Added conditional serial-number block using || operator
• Increased indentation for nested identifier fields
• Added quotes around ISBN value for consistency

jablib/src/main/resources/resource/layout/hayagrivayaml.layout


2. jablib/src/test/java/org/jabref/logic/exporter/HayagrivaYamlExporterTest.java 🧪 Tests +83/-0

Add tests for serial-number identifier nesting

• Added exportsDoiNestedUnderSerialNumber() test for DOI nesting
• Added exportsIsbnNestedUnderSerialNumber() test for ISBN nesting
• Added exportsIssnNestedUnderSerialNumber() test for ISSN nesting
• Each test validates correct YAML structure with serial-number block

jablib/src/test/java/org/jabref/logic/exporter/HayagrivaYamlExporterTest.java


3. CHANGELOG.md 📝 Documentation +2/-0

Document Hayagriva serial-number fix

• Added entry documenting the Hayagriva YAML exporter fix
• References issue #15713 and Hayagriva format specification compliance

CHANGELOG.md


Grey Divider

Qodo Logo

@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented May 17, 2026

Copy link
Copy Markdown
Contributor

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider


Action required

1. ISSN test missing assertion ✓ Resolved 📎 Requirement gap ≡ Correctness
Description
exportsIssnNestedUnderSerialNumber builds an expected YAML output but never asserts it against
the exported file contents, so ISSN serialization is not actually covered and regressions could slip
through. This violates the requirement to have unit tests validating ISSN is nested under
serial-number.issn (and not emitted as a top-level field).
Code

jablib/src/test/java/org/jabref/logic/exporter/HayagrivaYamlExporterTest.java[R323-333]

+        List<String> expected = List.of(
+                "test:",
+                "  type: article",
+                "  title: \"Test Article\"",
+                "  author:",
+                "    - Author, Test",
+                "  date: 2020-10-14",
+                "  url: http://example.com",
+                "  serial-number:",
+                "    issn: \"0896-3207\"");
+    }
Evidence
PR Compliance ID 2 requires unit tests that validate ISSN is serialized as serial-number.issn and
not as a top-level field. In exportsIssnNestedUnderSerialNumber, the test method ends immediately
after defining the expected output and does not include an `assertEquals(expected,
Files.readAllLines(file))`, unlike the DOI and ISBN tests in the same class which do assert the
exported file contents; therefore the ISSN behavior is not verified.

Hayagriva export nests ISBN and ISSN under serial-number and unit tests cover each identifier type
jablib/src/test/java/org/jabref/logic/exporter/HayagrivaYamlExporterTest.java[309-333]
jablib/src/test/java/org/jabref/logic/exporter/HayagrivaYamlExporterTest.java[253-279]
jablib/src/test/java/org/jabref/logic/exporter/HayagrivaYamlExporterTest.java[281-307]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The test `exportsIssnNestedUnderSerialNumber` currently constructs an `expected` YAML output but never compares it to the actual exporter output, meaning it cannot fail and does not validate that ISSN is nested under `serial-number` rather than emitted as a top-level YAML field.
## Issue Context
PR Compliance requires unit tests for DOI/ISBN/ISSN export verifying the identifiers are nested under `serial-number` and not emitted as top-level YAML fields. In the same test class, the DOI and ISBN tests use `assertEquals(expected, Files.readAllLines(file));`, but the ISSN test ends right after creating `expected` without asserting the file contents.
## Fix Focus Areas
- jablib/src/test/java/org/jabref/logic/exporter/HayagrivaYamlExporterTest.java[309-333]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Qodo Logo

@github-actions github-actions Bot added good first issue An issue intended for project-newcomers. Varies in difficulty. component: export-or-save labels May 17, 2026
@mollyytran mollyytran changed the title Fix for issue 15713 Fix Hayagriva export to nest identifiers under serial-number May 17, 2026
@jabref-machine

Copy link
Copy Markdown
Collaborator

Note that your PR will not be reviewed/accepted until you have gone through the mandatory checks in the description and marked each of them them exactly in the format of - [x] (done), - [ ] (yet to be done) or - [/] (not applicable). Please adhere to our pull request template.

@Siedlerchr

Copy link
Copy Markdown
Member

Next time do not modify the PR template! Ensure that you go through the checklist or we will close it without review

@Siedlerchr Siedlerchr added this pull request to the merge queue May 19, 2026
@github-actions github-actions Bot added the status: to-be-merged PRs which are accepted and should go into the merge-queue. label May 19, 2026
Merged via the queue into JabRef:main with commit 18ae7f0 May 19, 2026
53 of 54 checks passed
Siedlerchr added a commit that referenced this pull request May 20, 2026
* upstream/main:
  Update PULL_REQUEST_TEMPLATE.md (#15788)
  New Crowdin updates (#15787)
  Update heylogs to 0.18.0 and use github-actions format (#15786)
  Grand refactoring of the AI features (#15688)
  Chore(deps): Bump com.fasterxml:aalto-xml in /versions (#15782)
  Chore(deps): Bump org.junit:junit-bom from 6.0.3 to 6.1.0 in /versions (#15783)
  Fix default value for unwanted characters (#15743)
  Fix runner tag
  Fix runner for JBang (PR)
  Fix duplicate finder progress counter incrementing on empty queue polls (#15781)
  Refine JabKit CLI: positional input argument and check command group (#15759)
  Ignore exception in unregisterListener to prevent exception (#15761)
  Fix wrong usage of "key" (#15779)
  Fix Hayagriva export to nest identifiers under serial-number (#15750)
f0restron07 pushed a commit to f0restron07/jabref that referenced this pull request May 24, 2026
…15750)

* Fix Hayagriva export to nest DOI, ISBN, ISSN under serial- number

* Removed typo from hayagrivayaml.layout

* Add tests for Hayagriva serial-number export (issue JabRef#15713)

* Described change in CHANGELOG.md

* Add missing assertion in ISSN test

---------

Co-authored-by: mollyytran <mtrann91@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Compliance violation component: export-or-save good first issue An issue intended for project-newcomers. Varies in difficulty. status: changes-required Pull requests that are not yet complete status: to-be-merged PRs which are accepted and should go into the merge-queue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Hayagriva exporter writes DOI as plain field instead of serial-number

3 participants