Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

http exception should come with text #11223

Closed
3 tasks
koppor opened this issue Apr 18, 2024 · 7 comments · Fixed by #11490
Closed
3 tasks

http exception should come with text #11223

koppor opened this issue Apr 18, 2024 · 7 comments · Fixed by #11490
Assignees
Labels

Comments

@koppor
Copy link
Member

koppor commented Apr 18, 2024

The UX when a network error occurs, should be improved.

Currently:

  1. Create a new library
  2. Select "Springer" in "Web search"
  3. Search for "test"
  4. Result: 315947758-7a55a0b3-4c64-4301-bc3e-12436e175e69

Expanding the error results in

315948534-a3895c30-3c71-4479-98a3-ce5d5af502ed

Tasks

  • Expected output:

    HTTP error 403 occurred when fetching from {URL}.
    
  • The secrets should be removed from the URL. (Currently, the key is shown. See screenshot; the blurred part)


Other place, where it works as expected (!)

  1. I create an entry
  2. Navigate to "General"
  3. In the "File" field, "Download from URL"
    315949023-4486ff9a-dbd4-4955-b6b4-3a80489cea96
  4. I paste https://www.researchgate.net/profile/Joanna-Kosinska-3/publication/344415012_Autonomic_Management_Framework_for_Cloud-Native_Applications/links/5f73246a458515b7cf567d65/Autonomic-Management-Framework-for-Cloud-Native-Applications.pdf
  5. Output
    315950767-9109ecde-af82-400d-abd6-d0a94edde851
  • If possible, also add the API key removal, here, too.

The log file of JabRef shows the full exception:

315950983-aca228ed-2075-406e-814a-e9dc9b65dd39


@RehanChalana
Copy link
Contributor

I'd like to work on this issue, but I don't have a detailed plan yet. Could someone provide some guidance on the best way to approach this?

Thanks!

@koppor koppor added the FirstTimeCodeContribution Triggers GitHub Greeter Workflow label Jul 3, 2024
Copy link
Contributor

github-actions bot commented Jul 3, 2024

Welcome to the vibrant world of open-source development with JabRef!

Newcomers, we're excited to have you on board. Start by exploring our Contributing guidelines, and don't forget to check out our workspace setup guidelines to get started smoothly.

Having any questions or issues? Feel free to ask here on GitHub. Need help setting up your local workspace? Join the conversation on JabRef's Gitter chat. And don't hesitate to open a (draft) pull request early on to show the direction it is heading towards. This way, you will receive valuable feedback.

Happy coding! 🚀

@koppor
Copy link
Member Author

koppor commented Jul 3, 2024

@RehanChalana I am not sure how I can help you. Could you reproduce the output? If yes, then search in the code where the output is generated, how it flows through the code. And where the HTTP error message is shown. If not, please explain at which step you could not follow.

@RehanChalana
Copy link
Contributor

Yes i was able to reproduce the output and yes i am following the stack trace to understand the flow and the source of HTTP error.

Thanks for assistance

@RehanChalana
Copy link
Contributor

I am able to change the output to
image

by implementing this small change in the org/jabref/logic/importer/SearchBasedParserFetcher.java while catching IOException

throw new FetcherException((e.getCause().getMessage() + " while fetching from " +
urlForQuery).replaceAll("api_key.*","api_key=REDACTED"), e);

Is this approach correct? Are there any potential issues or side effects I should be aware of?

@Siedlerchr
Copy link
Member

Siedlerchr commented Jul 6, 2024 via email

@RehanChalana
Copy link
Contributor

They did , thank you for pointing this out.

In this case we can use a more general regular expression to check for potential parameters of api_key
throw new FetcherException((e.getCause().getMessage() + " while fetching from " + urlForQuery).replaceAll
("(?i)(api[_-]?key)=.*","[REDACTED]"), e);

This will make sure api is not exposed with different cases and formats (e.g., "api_key", "ApiKeY", "API-KEY", etc.)

I was able to reproduce the issue with other fetchers by selecting "Use Custom Key" and setting it to random value

image

Output:
image

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Development

Successfully merging a pull request may close this issue.

3 participants