Skip to content

[Port to black-forest] Handle missing entry types in shared databases - #15

Merged
koppor merged 4 commits into
black-forestfrom
port-17650-to-black-forest
Nov 4, 2026
Merged

koppor merged 4 commits into
black-forestfrom
port-17650-to-black-forest

Conversation

@jabref-machine

Copy link
Copy Markdown
Collaborator

Port of JabRef#17650 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.

### Summary

Shared database entry loading now falls back to `Misc` when the stored
entry type is null or blank, preventing malformed rows from crashing
JabRef. The behavior is covered by PostgreSQL-backed tests and an
OpenFastTrace requirement.

Analogies: Like honey, the fallback smooths a rough edge; like
chocolate, it makes an unpleasant database state easier to handle; like
the moon, it keeps the shared database visible when its type is missing.

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

### Steps to test

1. Set up a PostgreSQL shared database and connect JabRef to it.
2. Insert a shared entry whose `entrytype` is `NULL` or contains only
whitespace.
3. Reconnect or reload the shared database.
4. Confirm that JabRef loads the entry as `Misc`, preserves the entry,
and logs a warning instead of failing.

No screenshot is applicable because this is a backend-only robustness
change with no new or changed UI.

### Related issues and pull requests

Closes JabRef#15658

### AI usage

Codex (model GPT-5), AIL2: used for repository investigation,
implementation assistance, test creation, documentation updates, and
verification. The contributor reviewed, understood, and takes full
ownership of the submitted 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`): no new classes.
- [/] New packages annotated with `@NullMarked`
(`org.jspecify.annotations.NullMarked`): no new packages.
- [x] `Optional` consumed with `ifPresent` / `ifPresentOrElse` / `map` /
`orElseThrow` — never `orElse(unusedValue)` nor an `isPresent()` +
`get()` block.
- [x] `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.
- [x] 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.
- [x] Regexes use a precompiled `Pattern.compile(...)` constant, not
`String.matches(...)`.
- [x] Keep alphabetical ordering when adding variables or enum items.
- [x] 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.
- [x] 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): no new user-facing text.
- [/] Sentence case (not Title Case); no trailing `!`; labels do not end
with `:`: no new UI labels.
- [/] Variance expressed with placeholders (`"...: %0"`), not string
concatenation: no localized text added.

### Security

- [/] User-controlled data (request params, entry fields, file contents)
is HTML-escaped before being written into any `text/html` response: no
HTML response changed.

### Tests

- [x] 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,
and use `@TempDir` instead of manual temp directories.
- [/] Fetcher tests hit the live endpoints — no fetcher tests changed.

## 2. Verification commands

- [x] `./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.
- [x] `./gradlew javadoc`.
- [x] `npx markdownlint-cli2 "docs/**/*.md" "*.md"`.
- [x] `npm ci && npm run textlint` reports no misspellings.
- [/] Docker IntelliJ formatting: formatting was already clean after
rewrite validation.

## 3. Documentation

- [x] CHANGELOG.md entry added for the user-visible shared-database
robustness fix.
- [x] Searched for and linked the confident matching JabRef issue.
- [x] Requirement added to `docs/requirements/shared-database.md`.
- [x] Developer documentation/requirements updated for the changed
shared-database behavior.

## 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 include no screenshot because the change has no visible UI.
- [x] All HTML comments removed from the PR body.
- [x] PR created with `gh pr create --body-file <file>`.
- [/] No `TODO` placeholder was used because issue JabRef#15658 is identified.

</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
- [ ] I manually tested my changes in running JabRef (always required)
- [x] I added JUnit tests for changes (if applicable)
- [/] 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 388f89b)
@jabref-machine jabref-machine added the automerge PR is tagged with that label will be merged if workflows are green label Oct 31, 2026
@Siedlerchr
Siedlerchr added this pull request to the merge queue Nov 2, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Nov 2, 2026
@koppor
koppor enabled auto-merge November 4, 2026 21:10
@koppor
koppor added this pull request to the merge queue Nov 4, 2026
@koppor
koppor removed this pull request from the merge queue due to a manual request Nov 4, 2026
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@koppor
koppor enabled auto-merge November 4, 2026 21:58
@koppor
koppor added this pull request to the merge queue Nov 4, 2026
@github-actions github-actions Bot added the status: to-be-merged PRs which are accepted and should go into the merge-queue. label Nov 4, 2026
Merged via the queue into black-forest with commit f084e82 Nov 4, 2026
72 checks passed
@koppor
koppor deleted the port-17650-to-black-forest branch November 4, 2026 22:36
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 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.

3 participants