Skip to content

Handle missing entry types in shared databases - #17650

Merged
Siedlerchr merged 5 commits into
JabRef:mainfrom
Siedlerchr:fix/shared-db-missing-entry-type
Oct 31, 2026
Merged

Siedlerchr merged 5 commits into
JabRef:mainfrom
Siedlerchr:fix/shared-db-missing-entry-type

Conversation

@Siedlerchr

Copy link
Copy Markdown
Member

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

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): no new classes.
  • [/] New packages annotated with @NullMarked (org.jspecify.annotations.NullMarked): no new packages.
  • 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): 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

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

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

3. Documentation

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

4. Pull request

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

@qodo-code-review

Copy link
Copy Markdown
Contributor

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@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 Oct 31, 2026
@Siedlerchr Siedlerchr added the automerge PR is tagged with that label will be merged if workflows are green label Oct 31, 2026
@Siedlerchr
Siedlerchr enabled auto-merge October 31, 2026 15:06
@github-actions github-actions Bot removed the automerge PR is tagged with that label will be merged if workflows are green label Oct 31, 2026
…type' into fix/shared-db-missing-entry-type

* siedlerchr/fix/shared-db-missing-entry-type:
  Require Escape to close dialogs, except the document viewer (JabRef#17175)
@github-actions github-actions Bot added component: maintable status: changes-required Pull requests that are not yet complete labels Oct 31, 2026
@Siedlerchr
Siedlerchr disabled auto-merge October 31, 2026 16:51
@Siedlerchr
Siedlerchr enabled auto-merge October 31, 2026 16:51
@Siedlerchr Siedlerchr added status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers and removed status: changes-required Pull requests that are not yet complete labels Oct 31, 2026
@Siedlerchr
Siedlerchr disabled auto-merge October 31, 2026 19:48
@Siedlerchr
Siedlerchr merged commit 388f89b into JabRef:main Oct 31, 2026
@jabref-machine

Copy link
Copy Markdown
Collaborator

Successfully created backport PR for black-forest:

Siedlerchr added a commit to thesauravpoddar/forkedjabref that referenced this pull request Oct 31, 2026
* upstream/main:
  Align add field controls in entry types preferences (JabRef#17501)
  Handle missing entry types in shared databases (JabRef#17650)
  document dialog font preference investigation (JabRef#17531)
  Require Escape to close dialogs, except the document viewer (JabRef#17175)
  Keep local groups whose shared write failed when pulling metadata (JabRef#17324)
  Fix to correctly preserve group selection upon switching library tabs (JabRef#17569)
  AI chat: delete and retry in message context menu (JabRef#17151)
  Show fulltext lookup progress for entries searched from the menu (JabRef#17224)
  Fix JabKit ignoring the avoid-overwrite setting (JabRef#17566)
  Warn about duplicate keybindings in preferences (JabRef#17331)
  Keep main table tooltip open (JabRef#17578)
  PR to resolve the issue automatically generate the summary git commit message in JabRef library (JabRef#17521)
  Do not re-draft a PR because of the Qodo review its ready event started (JabRef#17647)
  New Crowdin updates (JabRef#17646)
  Update dependency jbangdev/jbang to v0.143.0 (JabRef#17641)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: maintable component: shared-database dev: send-to-black-forest Port to the black-forest branch of JabRef/jabref-black-forest after merging (ADR-0073) size: small status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Shared PostgreSQL database schema missing NOT NULL constraint on ENTRY TYPE column allows ghost entries.

2 participants