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

Log when source query parameter contains invalid values #3945

Closed
obulat opened this issue Mar 20, 2024 · 1 comment · Fixed by #3949
Closed

Log when source query parameter contains invalid values #3945

obulat opened this issue Mar 20, 2024 · 1 comment · Fixed by #3949
Assignees
Labels
💻 aspect: code Concerns the software code in the repository ✨ goal: improvement Improvement to an existing user-facing feature help wanted Open to participation from the community 🟩 priority: low Low priority and doesn't need to be rushed 🧱 stack: api Related to the Django API

Comments

@obulat
Copy link
Contributor

obulat commented Mar 20, 2024

Problem

In the API source parameter validation improvements discussion we decided to log when any of the sources in the API request parameters is invalid.

Description

Log whenever one of the sources in the search request is invalid. This is the code that needs to be updated:

sources = value.lower().split(",")
sources = [source for source in sources if source in allowed_sources]

We can add the following code:

sources = value.lower().split(",")
original_len = len(sources)
valid_sources = [source for source in sources if source in allowed_sources]
if original_len > len(sources):
    invalid_sources = set(sources).difference(set(valid_sources))
    logger.warn(f"Invalid sources in search query: {invalid_sources}")

Alternatives

We could also save the information about requests and invalid sources in Redis if that would be easier to query.

@obulat obulat added help wanted Open to participation from the community 🟩 priority: low Low priority and doesn't need to be rushed ✨ goal: improvement Improvement to an existing user-facing feature 💻 aspect: code Concerns the software code in the repository 🧱 stack: api Related to the Django API labels Mar 20, 2024
@openverse-bot openverse-bot moved this to 📋 Backlog in Openverse Backlog Mar 20, 2024
@manojks1999
Copy link
Contributor

manojks1999 commented Mar 20, 2024

Working on it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💻 aspect: code Concerns the software code in the repository ✨ goal: improvement Improvement to an existing user-facing feature help wanted Open to participation from the community 🟩 priority: low Low priority and doesn't need to be rushed 🧱 stack: api Related to the Django API
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants