Skip to content

API returns 500 error when combining title and author parameters #268

Description

@mtibke

The audiobooks API endpoint returns a 500 Internal Server Error when both title and author parameters are provided together.

Steps to Reproduce

Works (title only):
curl "https://librivox.org/api/feed/audiobooks?format=json&title=Adventskalender+2023"

Returns 200 with correct data

Fails (title + author):
curl "https://librivox.org/api/feed/audiobooks?format=json&title=Adventskalender+2023&author=Various"

Returns 500 Internal Server Error

Suspected Cause

In application/libraries/Librivox_API.php, the function _build_author_project_id_list() returns 0 (integer) when no matching author is found:

return (empty($project_ids)) ? 0 : $project_ids;

This value is then passed to where_in():
$this->db->where_in('p.id', $project_id_list);

CodeIgniter's where_in() expects an array, not an integer, which may cause the error.

Suggested Fix

return (empty($project_ids)) ? [] : $project_ids;
And add a check in _build_data_set() to skip the where_in clause if the array is empty.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:apiAPI and RSS - resources for third-party automed accessbuggood first issue

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions