Skip to content

Fix path conversion in JabKit pseudonymization#14125

Merged
Siedlerchr merged 3 commits into
JabRef:mainfrom
ravatex:fix-pseudonymize-args
Oct 21, 2025
Merged

Fix path conversion in JabKit pseudonymization#14125
Siedlerchr merged 3 commits into
JabRef:mainfrom
ravatex:fix-pseudonymize-args

Conversation

@ravatex

@ravatex ravatex commented Oct 20, 2025

Copy link
Copy Markdown
Contributor

Closes #14122

The infrastructure for figuring out a reasonable default path was already there, the logic was just a little bit off.
Now the output and key arguments should be actually optional.
Test it via $ jabkit pseudonymize --input any.bib

I was not able to find any automated CLI end to end testing I can implement. If there is a method inform me to add to this PR.

Mandatory checks

  • I own the copyright of the code submitted and I license it under the MIT license
  • 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 described the change in CHANGELOG.md in a way that is understandable for the average user (if change is visible to the user)
  • I checked the user documentation: Is the information available and up to date? If not, I created an issue at https://github.com/JabRef/user-documentation/issues or, even better, I submitted a pull request updating file(s) in https://github.com/JabRef/user-documentation/tree/main/en.

@github-actions

Copy link
Copy Markdown
Contributor

Hey @ravatex!

Thank you for contributing to JabRef! Your help is truly appreciated ❤️.

We have automatic checks in place, based on which you will soon get automated feedback if any of them are failing. We also use TragBot with custom rules that scans your changes and provides some preliminary comments, before a maintainer takes a look. TragBot is still learning, and may not always be accurate. In the "Files changed" tab, you can go through its comments and just click on "Resolve conversation" if you are sure that it is incorrect, or comment on the conversation if you are doubtful.

Please re-check our contribution guide in case of any other doubts related to our contribution workflow.

@subhramit subhramit 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.

Small possibility for more improvement.
When you go with this, also check if any test needs to be added/adapted for it.

Comment on lines 99 to 105
private Path resolveOutputPath(String customPath, Path inputPath, String defaultFileName) {
return customPath != null ? Path.of(customPath) : inputPath.getParent().resolve(defaultFileName);
return customPath != null ? Path.of(customPath) : inputPath.toAbsolutePath().getParent().resolve(defaultFileName);
}

private Path resolveOutputPath(Path customPath, Path inputPath, String defaultFileName) {
return customPath != null ? customPath : inputPath.toAbsolutePath().getParent().resolve(defaultFileName);
}

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.

Just an idea - I think now the keys file can also be input as a Path (by using Cygwin paths) instead of a String, and in that case the method below would be sufficient for both and the one above can be removed?

@subhramit subhramit changed the title fix: corrected path conversion logic Fix path conversion in JabKit pseudonymization Oct 21, 2025
@ravatex

ravatex commented Oct 21, 2025

Copy link
Copy Markdown
Contributor Author

I assumed there was a reason for originally having it as a string instead of a path. I can fix this.

Edit: There were no tests for this class, as it is just an argument interface for the Pseudonymization and mostly deals with IO. If you have E2E testing for CLI I would be happy to add them, but for now I cannot add them.

@subhramit subhramit requested a review from calixtus October 21, 2025 10:18
@subhramit

subhramit commented Oct 21, 2025

Copy link
Copy Markdown
Member

I think this should also go into the changelog.
Nope, nvm, this feature is unreleased.

@subhramit

Copy link
Copy Markdown
Member

Edit: There were no tests for this class, as it is just an argument interface for the Pseudonymization and mostly deals with IO. If you have E2E testing for CLI I would be happy to add them, but for now I cannot add them.

You can take a look at https://github.com/JabRef/jabref/blob/main/jabkit/src/test/java/org/jabref/cli/ArgumentProcessorTest.java
It is true that no tests were added during the inception of this in the CLI, but there should have been - so I think this is a good opportunity to introduce them.

@ravatex

ravatex commented Oct 21, 2025

Copy link
Copy Markdown
Contributor Author

Should I create a new issue for creating the rest of the CLI tests. I don't think it should be in this PR since there are opportunities for abstractions for nice CLI tests, adding it here seems not clean.

@subhramit

Copy link
Copy Markdown
Member

Should I create a new issue for creating the rest of the CLI tests. I don't think it should be in this PR since there are opportunities for abstractions for nice CLI tests, adding it here seems not clean.

Yes, that sounds good. We can consider this PR done in the current state.

@Siedlerchr Siedlerchr added this pull request to the merge queue Oct 21, 2025
Merged via the queue into JabRef:main with commit 2381aa2 Oct 21, 2025
58 of 66 checks passed
merlinymy pushed a commit to merlinymy/jabref that referenced this pull request Nov 19, 2025
* fix: corrected path conversion logic

* refactored keyFile to be Path

* fixed checkstyle violation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pseudonymization does not work correctly.

3 participants