-
Notifications
You must be signed in to change notification settings - Fork 0
fix: standalone bugfix batch (6 issues) #278
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| library(testthat) | ||
|
|
||
| source_app("api_openrouter.R") | ||
|
|
||
| test_that("extract_message_content returns normal string content", { | ||
| msg <- list(content = "Hello, world!") | ||
| expect_equal(extract_message_content(msg), "Hello, world!") | ||
| }) | ||
|
|
||
| test_that("extract_message_content returns reasoning when content is NULL", { | ||
| msg <- list(content = NULL, reasoning = "I reasoned this.") | ||
| expect_equal(extract_message_content(msg), "I reasoned this.") | ||
| }) | ||
|
|
||
| test_that("extract_message_content returns NULL when content and reasoning are NULL", { | ||
| msg <- list(content = NULL, reasoning = NULL) | ||
| expect_null(extract_message_content(msg)) | ||
| }) | ||
|
|
||
| test_that("extract_message_content falls through empty string to reasoning", { | ||
| msg <- list(content = "", reasoning = "fallback reasoning") | ||
| expect_equal(extract_message_content(msg), "fallback reasoning") | ||
| }) | ||
|
|
||
| test_that("extract_message_content returns empty string when no reasoning fallback", { | ||
| msg <- list(content = "") | ||
| # Content is empty, no reasoning → falls through and returns content as-is | ||
| expect_equal(extract_message_content(msg), "") | ||
| }) | ||
|
|
||
| test_that("extract_message_content falls through character(0) to reasoning", { | ||
| msg <- list(content = character(0), reasoning = "fallback reasoning") | ||
| expect_equal(extract_message_content(msg), "fallback reasoning") | ||
| }) | ||
|
|
||
| test_that("extract_message_content handles character(0) with no reasoning", { | ||
| msg <- list(content = character(0)) | ||
| # character(0) is empty, no reasoning → returns content as-is | ||
| expect_equal(extract_message_content(msg), character(0)) | ||
| }) | ||
|
|
||
| test_that("extract_message_content handles multi-element character vector", { | ||
| # This was the bug — nchar() on a vector yields a vector, if() errors | ||
| msg <- list(content = c("Hello", "World")) | ||
| expect_equal(extract_message_content(msg), c("Hello", "World")) | ||
| }) | ||
|
|
||
| test_that("extract_message_content concatenates list-of-parts content", { | ||
| msg <- list(content = list( | ||
| list(text = "Part one"), | ||
| list(text = "Part two") | ||
| )) | ||
| expect_equal(extract_message_content(msg), "Part one\nPart two") | ||
| }) | ||
|
|
||
| test_that("extract_message_content handles mixed list parts", { | ||
| msg <- list(content = list( | ||
| list(text = "Structured"), | ||
| "plain string" | ||
| )) | ||
| expect_equal(extract_message_content(msg), "Structured\nplain string") | ||
| }) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OA_CONTENT_DOWNLOAD_COST_USDis defined inconfig.R, butimport_single_paper()is sourced/used in at least one worker context that does not sourceconfig.R(e.g.,batch_import_taskinmod_search_notebook.Rsourcesimport_paper.Rwithoutconfig.R). In that path, evaluatingcost_usd = OA_CONTENT_DOWNLOAD_COST_USDwill fail and silently skip OA usage logging (caught bytryCatch). Consider either ensuring all entrypoints sourceconfig.Rbeforeimport_paper.R, or adding a local fallback (e.g., defaulting to 0.01 when the constant is not defined) so usage logging works consistently.