Skip to content

Conversation

@jameslamb
Copy link
Collaborator

@jameslamb jameslamb commented Dec 23, 2025

Fixes #259

Drops the dependency on {futile.logger}, to avoid {uptasticsearch} being archived on CRAN.

Notes for Reviewers

Design choices

I'm proposing here using the standard library and exposing a boolean verbose argument in the public API.

It's nice to be able to do stuff like this when you have multiple libraries all using {futile.logger}:

futile.logger::flog.threshold(
    futile.logger::INFO
)

Without needing any other code changes, but honestly I think giving that up is worth it in exchange for cutting out another dependency and reducing the risk of {uptasticsearch} being archived on CRAN if something like this happens again.

rejected ideas (click me)
  • vendoring the relevant parts of {futile.logger} (it's LGPL-3 though so... I don't love that option)
  • using another third-party logging library like {logger} (see CRAN warning: {futile.logger} set to be archived pkgnet#336 (comment))
  • implementing something with options() that allows users to set the log level without needing to pass an argument to every {uptasticsearch} call
  • moving {futile.logger} to a Suggests dependency and falling back to this standard-lib-only implementation only if it's unavailable (tbh, not sure if CRAN would let us stay with even a Suggests dependency on an archived package though)

How I tested this

Ran the integration tests, which hit Elasticsearch running locally in a container.

how I did that (click me)
R CMD INSTALL ./r-pkg
export NOT_CRAN=true
./setup_local.sh 8.17.2
pushd ./r-pkg/tests
Rscript testthat.R
popd

Also ran the following small script, to see the effect of the logging.

./setup_local.sh 8.17.2

cat > test-verbose.R <<EOF
outDT <- uptasticsearch::es_search(
    es_host = "http://127.0.0.1:9200"
    , es_index = "shakespeare"
    , max_hits = 30
    , size = 2
)
EOF
$ Rscript ./test-verbose.R
INFO [2025-12-22 22:43:55] Executing search request
INFO [2025-12-22 22:43:55] Checking Elasticsearch version...
INFO [2025-12-22 22:43:55] uptasticsearch thinks you are running Elasticsearch 8.17.2
INFO [2025-12-22 22:43:55] Total hits to pull: 30
INFO [2025-12-22 22:43:55] Scrolling over additional pages of results...
INFO [2025-12-22 22:43:55] Checking Elasticsearch version...
INFO [2025-12-22 22:43:55] uptasticsearch thinks you are running Elasticsearch 8.17.2
INFO [2025-12-22 22:43:55] Pulled 4 of 30 results
INFO [2025-12-22 22:43:55] Pulled 6 of 30 results
INFO [2025-12-22 22:43:55] Pulled 8 of 30 results
INFO [2025-12-22 22:43:55] Pulled 10 of 30 results
INFO [2025-12-22 22:43:55] Pulled 12 of 30 results
INFO [2025-12-22 22:43:55] Pulled 14 of 30 results
INFO [2025-12-22 22:43:55] Pulled 16 of 30 results
INFO [2025-12-22 22:43:55] Pulled 18 of 30 results
INFO [2025-12-22 22:43:55] Pulled 20 of 30 results
INFO [2025-12-22 22:43:55] Pulled 22 of 30 results
INFO [2025-12-22 22:43:55] Pulled 24 of 30 results
INFO [2025-12-22 22:43:55] Pulled 26 of 30 results
INFO [2025-12-22 22:43:55] Pulled 28 of 30 results
INFO [2025-12-22 22:43:55] Pulled 30 of 30 results
INFO [2025-12-22 22:43:55] Done scrolling over results.
INFO [2025-12-22 22:43:55] Reading and parsing pulled records...
INFO [2025-12-22 22:43:55] Done reading and parsing pulled records.

The logs look exactly the same on main.

$ git checkout main
$ Rscript -e "remove.packages('uptasticsearch')"
$ R CMD INSTALL ./r-pkg
$ Rscript ./test-verbose.R
INFO [2025-12-22 22:43:55] Executing search request
INFO [2025-12-22 22:43:55] Checking Elasticsearch version...
INFO [2025-12-22 22:43:55] uptasticsearch thinks you are running Elasticsearch 8.17.2
INFO [2025-12-22 22:43:55] Total hits to pull: 30
...
INFO [2025-12-22 22:43:55] Reading and parsing pulled records...
INFO [2025-12-22 22:43:55] Done reading and parsing pulled records.

Also killed the local container and tried again, to show the FATAL-level logging

$ ./cleanup_local.sh
$ Rscript ./test-verbose.R
INFO [2025-12-22 22:52:40] Executing search request
Error in curl::curl_fetch_memory(url = url, handle = handle) : 
  Could not connect to server [127.0.0.1]: Failed to connect to 127.0.0.1 port 9200 after 0 ms: Could not connect to server
Calls: <Anonymous> ... .request -> .retry -> <Anonymous> -> raise_libcurl_error
Execution halted

@jameslamb jameslamb added the maintenance miscellaneous maintenance label Dec 23, 2025
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
rev: v6.0.0
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just ran pre-commit autoupdate to pull in new updates... might as well since while we're touching the repo 🤷🏻

uses: actions/checkout@v5
with:
fetch-depth: 0
persist-credentials: false
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another tiny change I wanted to slip in here since we're touching the repo for the first time in months.

This is a small security patch that avoids storing the temporary git creds created by actions/checkout, which makes it harder for injected code to do bad things.

#' all possible hits will be pulled.
#' @param size Number of records per page of results.
#' See \href{https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-body.html#request-body-search-from-size}{Elasticsearch docs} for more.
#' See \href{https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-scroll}{Elasticsearch docs} for more.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

R CMD check was raising this NOTE:

Found the following (possibly) invalid URLs:
  URL: https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-body.html#request-body-search-from-size (moved to https://www.elastic.co/guide/en/elasticsearch/reference/8.18/search-request-body.html#request-body-search-from-size)
    From: man/es_search.Rd
    Status: 200
    Message: OK
  URL: https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-body.html#request-body-search-scroll (moved to https://www.elastic.co/guide/en/elasticsearch/reference/8.18/search-request-body.html#request-body-search-scroll)
    From: man/es_search.Rd
    Status: 200
    Message: OK

@jameslamb jameslamb changed the title WIP: remove dependency on {futile.logger} remove dependency on {futile.logger} Dec 23, 2025
@jameslamb jameslamb marked this pull request as ready for review December 23, 2025 05:06
Copy link
Collaborator

@austin3dickey austin3dickey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks! Logs look good in my testing!

Image

expect_null(chompDT)
})

##### TEST TEAR DOWN #####
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, nice to remove these

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

Labels

maintenance miscellaneous maintenance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CRAN warning: {futile.logger} set to be archived

2 participants