Skip to content

[Port to black-forest] Fix Hayagriva export for performance and custom entry types - #23

Open
jabref-machine wants to merge 1 commit into
black-forestfrom
port-17815-to-black-forest
Open

jabref-machine wants to merge 1 commit into
black-forestfrom
port-17815-to-black-forest

Conversation

@jabref-machine

Copy link
Copy Markdown
Collaborator

Port of JabRef#17815 to black-forest, see Branching strategy.

If this PR is a draft, the cherry-pick conflicted: the conflicting files are committed with Git's conflict markers left in. Resolve the markers locally, push, and mark the PR ready.

…7815)

### 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:
```bibtex
   @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}
   }
```
<img width="2560" height="1392" alt="Skärmbild (515)"
src="https://github.com/user-attachments/assets/d4854c55-a02a-41a9-aa71-05b36c89fefe"
/>

4. Export the library with the "Hayagriva YAML" format and save the
file.
<img width="348" height="111" alt="Skärmbild (516)"
src="https://github.com/user-attachments/assets/122bc590-e92e-4b52-bb1a-3271b9c18f22"
/>

5. 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
<img width="2565" height="1326" alt="Skärmbild (517)"
src="https://github.com/user-attachments/assets/ddbb065c-46d6-4ab6-935b-47a5ee675f29"
/>

### Related issues and pull requests

Closes JabRef#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.

<details>
<summary>AI CHECKLIST.md walkthrough</summary>

## 1. Code self-review

### Nullability and control flow

- [x] No `== null` / `!= null` checks — JSpecify annotations
(`@NullMarked`, `@Nullable`, `@NonNull`) used instead.
- [x] 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

- [x] No `catch (Exception e)` — only specific exceptions are caught.
- [x] 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

- [x] New `BibEntry` objects built with withers (`withField`, not
`setField`).
- [x] 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()`.
- [x] 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.
- [x] Behavior changes in `org.jabref.model` / `org.jabref.logic` have
added or updated tests.
- [x] 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).
- [x] `./gradlew checkstyleMain checkstyleTest checkstyleJmh`.
- [x] `./gradlew modernizer`.
- [x] `./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

- [x] `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](https://github.com/JabRef/jabref/issues)
and
[jabref-koppor/issues](https://github.com/JabRef/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

- [x] PR body built from `.github/PULL_REQUEST_TEMPLATE.md`, every
section filled.
- [x] 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).
- [x] 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.

</details>

### Checklist

- [x] I own the copyright of the code submitted and I license it under
the [MIT license](https://github.com/JabRef/jabref/blob/main/LICENSE)
- [x] 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
- [x] I manually tested my changes in running JabRef (always required)
- [x] I added JUnit tests for changes (if applicable)
- [x] I added screenshots in the PR description (if change is visible to
the user)
- [x] 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](https://docs.jabref.org/) for
up to dateness and submitted a pull request to our [user documentation
repository](https://github.com/JabRef/user-documentation/tree/main/en)

(cherry picked from commit f1d2d3a)
@jabref-machine jabref-machine added the automerge PR is tagged with that label will be merged if workflows are green label Nov 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automerge PR is tagged with that label will be merged if workflows are green

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants