Add valiation to cite command#15063
Conversation
Fix WARN for incorrect completeCiteCommand Co-authored-by: koppor <1366654+koppor@users.noreply.github.com>
Review Summary by QodoAdd validation warning for citation command placeholders
WalkthroughsDescription• Add validation for citation command placeholders in preferences • Display warning when cite command missing required key1/key2 placeholders • Make CITE_KEY constants public for validator access • Change log level from info to warn for invalid cite commands Diagramflowchart LR
A["User modifies cite command"] --> B["ExternalTab initializes validation"]
B --> C["citeCommandValidator checks placeholders"]
C --> D{Contains key1 and key2?}
D -->|Yes| E["No warning displayed"]
D -->|No| F["Warning message shown to user"]
G["CitationCommandString.from()"] --> H["Logs warning if invalid"]
File Changes1. jabgui/src/main/java/org/jabref/gui/preferences/external/ExternalTab.java
|
|
The title of the pull request must not start with "Fix for issue xyz". Please use a concise one-line summary that explains what the fix or change actually does. Example of a good title: "Prevent crash when importing malformed BibTeX entries". |
Code Review by Qodo
✅ 1.
|
| - We added the ability to copy selected text from AI chat interface. [#14655](https://github.com/JabRef/jabref/issues/14655) | ||
| - We added cover images for books, which will display in entry previews if available, and can be automatically downloaded when adding an entry via ISBN. [#10120](https://github.com/JabRef/jabref/issues/10120) | ||
| - We added API key configuration support for [OpenAlex](https://openalex.org/). [#15023](https://github.com/JabRef/jabref/pull/15023) | ||
| - We added a warning if the citation command does not contain the expected place holders. |
There was a problem hiding this comment.
1. Changelog says place holders 📘 Rule violation ✓ Correctness
• The new changelog entry uses the misspelling place holders instead of placeholders. • This violates the requirement to keep changelog/user-facing text free of typographical errors and reduces professionalism/clarity.
Agent Prompt
## Issue description
The changelog entry contains a typographical error: `place holders` should be `placeholders`.
## Issue Context
Compliance requires changelog text to be free of misspellings.
## Fix Focus Areas
- CHANGELOG.md[25-25]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| validator.addValidators(citeCommandValidator); | ||
|
|
||
| ValidationStatus validationStatus = validator.getValidationStatus(); | ||
| if (!validationStatus.isValid()) { | ||
| validationStatus.getHighestMessage().ifPresent(message -> |
There was a problem hiding this comment.
2. Warning blocks preferences 🐞 Bug ✓ Correctness
• The new cite-command validator emits a ValidationMessage.warning, but it is added to the CompositeValidator used by validateSettings(), which blocks saving/closing when ValidationStatus is not valid. • In this codebase, warnings still flip ValidationStatus.validProperty()/isValid to false (used elsewhere for a “duplicate DOI” warning), so users with a non-conforming cite command will be prevented from saving preferences and will see an error dialog for a warning-level message.
Agent Prompt
### Issue description
The cite command validator is configured as a *warning*, but it is added to `validateSettings()`’s blocking `CompositeValidator`. In this app’s validation usage, warnings still cause `ValidationStatus` to be invalid, so this will prevent users from closing/saving Preferences and will surface the warning via an error dialog.
### Issue Context
This PR aims to “add a warning if the citation command does not contain the expected place holders”, which suggests non-blocking guidance. However, adding it to `validateSettings()` makes it blocking.
### Fix Focus Areas
- jabgui/src/main/java/org/jabref/gui/preferences/external/ExternalTabViewModel.java[93-101]
- jabgui/src/main/java/org/jabref/gui/preferences/external/ExternalTabViewModel.java[154-174]
### Implementation notes
Choose one:
1) **Non-blocking warning**: remove `citeCommandValidator` from the `CompositeValidator` in `validateSettings()` and rely on the visual decoration; optionally show a non-blocking warning dialog.
2) **Blocking validation**: change `ValidationMessage.warning(...)` to `ValidationMessage.error(...)` and adjust message/changelog to match enforced behavior.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
There was a problem hiding this comment.
Ask❓
@Siedlerchr This is OK, isn't it?
Answer:
Not quite. With the current code, this is not “just a warning” in terms of behavior.
Because you add citeCommandValidator to the CompositeValidator in validateSettings():
validator.addValidators(citeCommandValidator);and validateSettings() blocks closing/saving when validationStatus.isValid() is false, any warning-level ValidationMessage will still typically make ValidationStatus invalid in this codebase (as the bot noted). Result:
- Users with a non-conforming cite command will be prevented from saving/closing Preferences
- The warning text will be shown via
showErrorDialogAndWait(...), i.e., as an error dialog - This contradicts the PR intention (“added a warning…”), which implies non-blocking guidance
Recommended fix (pick one based on intended UX):
-
Non-blocking warning (likely intended):
- Keep the visual validation decoration (
initVisualization(...)) so users see the warning inline - Remove
citeCommandValidatorfrom the blockingvalidateSettings()composite validator - Optionally show a non-blocking notification/toast instead of an error dialog if you still want extra visibility
- Keep the visual validation decoration (
-
Make it truly blocking validation:
- Change
ValidationMessage.warning(...)toValidationMessage.error(...) - Update wording/Changelog to reflect that the cite command is now enforced (not merely warned)
- Change
Given the changelog text and issue description, option (1) seems the correct behavior.
|
|
||
| ValidationStatus validationStatus = validator.getValidationStatus(); | ||
| if (!validationStatus.isValid()) { | ||
| validationStatus.getHighestMessage().ifPresent(message -> |
There was a problem hiding this comment.
The bot is right here I think
There was a problem hiding this comment.
Probably yes, but requires some more refactoring / rewording, just to have to code more expressive. So i would just let it slip and create a follow-up issue.
Closes JabRef#723
Closes JabRef#725 (because ported to here)
Steps to test
JabRef#723
Mandatory checks
CHANGELOG.mdin a way that is understandable for the average user (if change is visible to the user)