Skip to content

Fix Hayagriva export for performance and custom entry types - #17815

Merged
koppor merged 2 commits into
JabRef:mainfrom
nysta12:fix-for-issue-17620
Nov 14, 2026
Merged

koppor merged 2 commits into
JabRef:mainfrom
nysta12:fix-for-issue-17620

Conversation

@nysta12

@nysta12 nysta12 commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

Summary

The Hayagriva YAML export crashed with an IllegalArgumentException for any entry whose type is not in StandardEntryType, such as @performance, which aborted the whole export. HayagrivaType now resolves the type with EntryTypeFactory.parse instead of StandardEntryType.valueOf, maps @performance to type: performance, and falls back to the existing Misc for types without a mapping.

Notes for reviewers:

  • The fallback is still Misc, to keep current output and the existing test formatsContentCorrect unchanged. Hayagriva types are lowercase, so should the fallback become misc?
  • CSLType uses the same valueOf pattern, which affects the CSL YAML export. I left it out of this PR to keep it focused.

jabref-contrib-policy:4.2:reviewed​:ok

Steps to test

  1. Start JabRef from this branch and create a new library (BibLaTeX mode).
  2. Paste the following two entries into the entry table:
   @performance{Example2024Performance,
     title      = {Example Performance Title},
     author     = {Example Author},
     date       = {2024-09-12},
     venue      = {Example Venue},
     location   = {Example City},
     eventtitle = {Example Event},
     type       = {Spoken Word Performance},
     url        = {https://example.org/event}
   }
 
   @article{Example2024Article,
     title   = {Example Article},
     author  = {Example Author},
     journal = {Example Journal},
     date    = {2024-01-01}
   }
Skärmbild (515)
  1. Export the library with the "Hayagriva YAML" format and save the file.
Skärmbild (516)
  1. The export completes without an error. In the saved file, the performance entry has type: performance and the article has type: article. Bottom right of the image says "Exportåtgärden slutfördes", which translates to that the export was successful
Skärmbild (517)

Related issues and pull requests

Closes #17620

AI usage

  • Claude Code (model claude-opus-5-5), used in read-only plan mode to explain the export code and plan the fix with me. I made the code and tested changes myself and wrote the changelog entry.
  • AI Influence Level: AIL1
    I reviewed, tested, and understand all changes.
AI CHECKLIST.md walkthrough

1. Code self-review

Nullability and control flow

  • No == null / != null checks — JSpecify annotations (@NullMarked, @Nullable, @NonNull) used instead.
  • No Objects.requireNonNull(...) — nullability expressed via JSpecify annotations.
  • [/] New classes annotated with @NullMarked (org.jspecify.annotations.NullMarked).
  • [/] New packages annotated with @NullMarked (org.jspecify.annotations.NullMarked).
  • [/] Optional consumed with ifPresent / ifPresentOrElse / map / orElseThrow — never orElse(unusedValue) nor an isPresent() + get() block.
  • [/] StringUtil.isBlank(...) used instead of s == null || s.isBlank().

Exceptions

  • No catch (Exception e) — only specific exceptions are caught.
  • No throw new RuntimeException(...) / IllegalStateException(...) — these tear down the whole application.
  • [/] Logged exceptions are passed as the last logger argument (LOGGER.info("...", e)), not concatenated into the message string.

Style and idioms

  • New BibEntry objects built with withers (withField, not setField).
  • Modern Java used: List.of() / Map.of() / Set.of(), Path.of(), SequencedCollection / SequencedSet, text blocks.
  • [/] Regexes use a precompiled Pattern.compile(...) constant, not String.matches(...).
  • [/] Keep alphabetical ordering when adding variables or enum items.
  • [/] Background work uses org.jabref.logic.util.BackgroundTask, not new Thread().
  • No commented-out code, no trivial comments restating the code, no AI-disclosure comments in source.
  • [/] Markdown Javadoc (///) uses Markdown syntax, not JavaDoc inline tags: `code` instead of {@code}, [ClassName] instead of {@link}.

User-facing text

  • [/] All user-facing text localized (Localization.lang in Java, % prefix in FXML).
  • [/] Sentence case (not Title Case); no trailing !; labels do not end with :.
  • [/] Variance expressed with placeholders ("...: %0"), not string concatenation.

Security

  • [/] User-controlled data (request params, entry fields, file contents) is HTML-escaped before being written into any text/html response — including exception/error messages, not just the success body (XSS).

Tests

  • In case issue lists an example, this concrete example is covered by a test case.
  • Behavior changes in org.jabref.model / org.jabref.logic have added or updated tests.
  • Tests assert object contents (assertEquals), use plain JUnit asserts (not AssertJ), have no @DisplayName, do not catch exceptions (let them propagate so JUnit reports setup/teardown failures directly), and use @TempDir instead of manual temp directories.
  • [/] Fetcher tests hit the live endpoints — the remote API is not mocked or stubbed (automated-review suggestions to mock it are rejected on purpose).

2. Verification commands

  • ./gradlew :jablib:check (or ./gradlew check for all modules).
  • ./gradlew checkstyleMain checkstyleTest checkstyleJmh.
  • ./gradlew modernizer.
  • ./gradlew --no-configuration-cache :rewriteDryRun reports no changes (run ./gradlew rewriteRun to fix).
  • ./gradlew javadoc.
  • npx markdownlint-cli2 "docs/**/*.md" "*.md" (only if Markdown changed).
  • npm ci && npm run textlint reports no misspellings (only if Markdown changed).
  • [/] Only if formatting is still off after rewriteRun: docker run -v $(pwd):/github/workspace ghcr.io/leventebajczi/intellij-format:master "*.java" "" ".idea/codeStyles/Project.xml".

3. Documentation

  • CHANGELOG.md entry added if the change is visible to the user (end-user wording, no extra blank lines, sorted in next to existing entries about the same component/feature). Link the issue if one exists; link the PR only when no issue exists. Use TODO as the placeholder when neither is known yet — never a fake number. No entry for fixes to changes that were themselves introduced after the last release (feature only in ## [Unreleased]) — update the existing unreleased entry instead if needed.
  • Searched jabref/issues and jabref-koppor/issues for a related issue; linked only on a confident match, otherwise kept TODO (no closes/fixes for merely-similar issues).
  • [/] Requirement added to docs/requirements/<area>.md if the change is a new feature or significant bug fix (skip for refactors, minor fixes, and internal changes).
  • [/] Developer documentation under docs/ updated if behavior or architecture changed.

4. Pull request

  • PR body built from .github/PULL_REQUEST_TEMPLATE.md, every section filled.
  • All checklist items kept and marked [x], [ ], or [/].
  • "Steps to test" is a numbered list with a cropped screenshot of the result for every visible change; no video (only allowed when another program is involved, e.g. drag and drop or push to an external application).
  • All HTML comments removed from the PR body.
  • [/] PR created with gh pr create --body-file <file> (not --body).
  • [/] If CHANGELOG.md used a TODO placeholder (no issue confidently identified yet — an existing issue link always stays), the PR was opened as draft, the placeholder was replaced with the real PR-number link after PR creation, committed and pushed, and only then was the PR marked ready for review. If an issue is identified or created later, the link is switched to the issue.

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 one sentence (max 20 words) to CHANGELOG.md describing the change from the user's point of view (if the 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

Copy link
Copy Markdown
Contributor

Hey @nysta12! 👋

Thank you for contributing to JabRef!

We have automated checks in place, based on which you will soon get feedback if any of them are failing. We also use Qodo for review assistance. It will update your pull request description with a review help and offer suggestions to improve the pull request.

After all automated checks pass, a maintainer will also review your contribution. Once that happens, you can go through their comments in the "Files changed" tab and act on them, or reply to the conversation if you have further inputs. You can read about the whole pull request process in our contribution guide.

Please ensure that your pull request is in line with our AI Usage Policy and make necessary disclosures.

@jabref-machine jabref-machine added the dev: send-to-black-forest Port to the black-forest branch of JabRef/jabref-black-forest after merging (ADR-0073) label Nov 13, 2026
@qodo-free-for-open-source-projects

Copy link
Copy Markdown
Contributor

PR Summary by Qodo

Fix Hayagriva export for performance and custom entry types

🐞 Bug fix 🕐 10-20 Minutes

Grey Divider

AI Description

• Prevent Hayagriva YAML exports from failing on performance and custom entry types.
• Export performances as performance and retain the existing Misc fallback for unmapped types.
• Add export tests for both entry types.
Diagram

graph TD
  A["Bib entry"] --> B["YAML template"] --> C["HayagrivaType"] --> D["EntryTypeFactory"] --> E{"Mapped type?"}
  E -->|Yes| F["Hayagriva type"]
  E -->|No| G["Misc fallback"]
Loading
High-Level Assessment

Using the existing EntryTypeFactory is the appropriate focused fix: it recognizes nonstandard types without changing established mappings or the Misc fallback. Catching failures from StandardEntryType.valueOf would still require separate logic to identify performance entries.

Files changed (3) +66 / -14

Bug fix (1) +18 / -14
HayagrivaType.javaResolve nonstandard types during Hayagriva formatting +18/-14

Resolve nonstandard types during Hayagriva formatting

• Replaces standard-enum lookup with EntryTypeFactory parsing so nonstandard and unknown types do not throw. Maps performance to 'performance' while preserving existing mappings and the 'Misc' fallback.

jablib/src/main/java/org/jabref/logic/layout/format/HayagrivaType.java

Tests (1) +47 / -0
HayagrivaYamlExporterTest.javaCover performance and unknown-type YAML exports +47/-0

Cover performance and unknown-type YAML exports

• Adds exporter tests asserting the complete YAML output for a performance entry and a custom entry type. The tests verify 'type: performance' and the retained 'type: Misc' fallback.

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

Documentation (1) +1 / -0
CHANGELOG.mdDocument the Hayagriva export fix +1/-0

Document the Hayagriva export fix

• Adds a user-facing note that libraries containing performance or custom entry types can now be exported as Hayagriva YAML.

CHANGELOG.md

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

qodo-free-for-open-source-projects Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Code Review by Qodo

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

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review

Grey Divider

Tip of the day
💡 Did you know, you can start a comment with 'qodo' or '@qodo' to chat about any finding

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

@github-actions github-actions Bot added component: bib(la)tex status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers and removed component: bib(la)tex status: changes-required Pull requests that are not yet complete labels Nov 13, 2026
@koppor

koppor commented Nov 14, 2026

Copy link
Copy Markdown
Member

Note that I am rewriting the exporter in a different way at JabRef#736

It is currently stalled, because other PRs need to get handled first.

@koppor koppor left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code-wise looks good. Let's get this in.

@koppor
koppor added this pull request to the merge queue Nov 14, 2026
@github-actions github-actions Bot added status: to-be-merged PRs which are accepted and should go into the merge-queue. and removed status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers labels Nov 14, 2026
Merged via the queue into JabRef:main with commit f1d2d3a Nov 14, 2026
77 checks passed
@jabref-machine

Copy link
Copy Markdown
Collaborator

Siedlerchr added a commit to benbbj/jabref that referenced this pull request Nov 14, 2026
* refs/heads/main: (219 commits)
  Update dependency com.konghq:unirest-modules-gson to v4.11.6 (JabRef#17818)
  New Crowdin updates (JabRef#17816)
  Fix Hayagriva export for performance and custom entry types (JabRef#17815)
  Speed up sorting the main table by caching collation keys (JabRef#17762)
  Preserve literal characters in HTML paragraphs (JabRef#17779)
  Count braced organizations as one editor (JabRef#17781)
  Add Markdown publication exporter (JabRef#17598)
  Change OK button to Remove in three confirmation dialogs (JabRef#17565)
  Add Test Cases For File-link Scenarios (JabRef#17645)
  Preserve uppercase named entities in HTML export (JabRef#17777)
  Improve icon colors and Shorten read-status and priority labels (JabRef#17691)
  Show effective file directory as prompt text in library properties (JabRef#17581)
  Chore(deps): Bump com.konghq:unirest-java-bom from 4.11.4 to 4.11.5 in /versions (JabRef#17813)
  Chore(deps): Bump org.apache.commons:commons-lang3 from 3.21.0 to 3.22.0 in /versions (JabRef#17814)
  New Crowdin updates (JabRef#17812)
  chore(deps): update dependency com.konghq:unirest-modules-gson to v4.11.5 (JabRef#17811)
  Added the word AS to the list of function words and JUnit Tests (JabRef#17751)
  Chore(deps): Bump org.bouncycastle:bcprov-jdk18on from 1.86 to 1.87 in /versions (JabRef#17807)
  Chore(deps): Bump com.dlsc.gemsfx:gemsfx from 4.7.0 to 4.9.0 in /versions (JabRef#17806)
  Chore(deps): Bump gradle-wrapper from 9.9.0 to 9.9.1 (JabRef#17805)
  ...
Siedlerchr added a commit that referenced this pull request Nov 15, 2026
…-built-in-journals

* upstream/main: (22 commits)
  New Crowdin updates (#17824)
  Add macOS text editing shortcuts (#17772)
  Close PRs for issues that still need triage (#17822)
  Update dependency com.konghq:unirest-modules-gson to v4.11.7 (#17820)
  Use JGit to match .gitignore rules in unlinked files search (#17656)
  Update dependency com.konghq:unirest-modules-gson to v4.11.6 (#17818)
  New Crowdin updates (#17816)
  Fix Hayagriva export for performance and custom entry types (#17815)
  Speed up sorting the main table by caching collation keys (#17762)
  Preserve literal characters in HTML paragraphs (#17779)
  Count braced organizations as one editor (#17781)
  Add Markdown publication exporter (#17598)
  Change OK button to Remove in three confirmation dialogs (#17565)
  Add Test Cases For File-link Scenarios (#17645)
  Preserve uppercase named entities in HTML export (#17777)
  Improve icon colors and Shorten read-status and priority labels (#17691)
  Show effective file directory as prompt text in library properties (#17581)
  Chore(deps): Bump com.konghq:unirest-java-bom from 4.11.4 to 4.11.5 in /versions (#17813)
  Chore(deps): Bump org.apache.commons:commons-lang3 from 3.21.0 to 3.22.0 in /versions (#17814)
  New Crowdin updates (#17812)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: bib(la)tex component: export-or-save dev: send-to-black-forest Port to the black-forest branch of JabRef/jabref-black-forest after merging (ADR-0073) first contrib size: small 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 YAML export crashes on @performance entries: No enum constant StandardEntryType.Performance

3 participants