Skip to content

Spotlight defaults are overwritten by blacklight #2928

@jcoyne

Description

@jcoyne

I'm seeing some cases in a development server (puma) where these values are not "remembered" by the code that needs them.

https://github.com/projectblacklight/spotlight/blob/main/lib/spotlight/engine.rb#L251-L262

This is manifesting as:

Blacklight::Exceptions::InvalidRequest in Spotlight::CatalogController#admin
RSolr::Error::Http - 400 Bad Request
Error: Can't determine a Sort Order (asc or desc) in sort spec ' desc', pos=5

because blacklight_config.index.timestamp_field is nil when we try to use it here:

solr_params = { sort: "#{blacklight_config.index.timestamp_field} desc" }

When I set a breakpoint in the Engine and one where the value is used it appears to be a different object:

# In the Engine
(ruby) Blacklight::Configuration.default_values[:index].object_id
85700
# In the SearchBuilder
Blacklight::Configuration.default_values[:index].object_id
156400
Blacklight::Configuration.default_values[:index].thumbnail_field
nil

This happens because the Blacklight initializer runs later and overwrites the configs set by Spotlight: https://github.com/projectblacklight/blacklight/blob/9e517006cf8373af1d623c2664276038a2258b2e/lib/blacklight/engine.rb#L9-L11

This was introduced in projectblacklight/blacklight#2826

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    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