Skip to content

CAMEL-24346: camel-google-sheets - number every range and tolerate a range without values - #25400

Merged
davsclaus merged 1 commit into
apache:mainfrom
oscerd:fix/CAMEL-24346
Aug 7, 2026
Merged

CAMEL-24346: camel-google-sheets - number every range and tolerate a range without values#25400
davsclaus merged 1 commit into
apache:mainfrom
oscerd:fix/CAMEL-24346

Conversation

@oscerd

@oscerd oscerd commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Two defects in GoogleSheetsStreamConsumer, both covered by a new test.

1. splitResults reported range index 1 for every value. The counter was allocated inside the
loop over the ranges:

for (ValueRange valueRange : response.getValueRanges()) {
    AtomicInteger rangeIndex = new AtomicInteger(1);
    ...
    rangeIndex.incrementAndGet();   // dead: a fresh counter next iteration
}

So a consumer configured with range=A1:B2,C1:D2&splitResults=true sent every exchange with
CamelGoogleSheetsRangeIndex=1, and there was no way to tell which range a value came from. The
counter now spans the whole response, which is what the non-split branch already did.

2. A range without values threw. valueRange.getValues() was dereferenced directly in both
branches, but the Sheets API omits the values field for a range that holds nothing, so polling a
spreadsheet with an empty range failed with a NullPointerException on every cycle.

Two smaller things while in there: the exchange building moved into createExchanges(List<ValueRange>)
so it can be tested without a Google client (the API client needs a real transport), and the branch
that reads a whole spreadsheet — used when no range is configured — now calls forceConsumerAsReady()
as well, so the consumer health check reports ready on that path too.

Claude Code on behalf of oscerd

🤖 Generated with Claude Code

…range without values

With splitResults the range counter was allocated inside the per-range loop, so
every exchange carried CamelGoogleSheetsRangeIndex=1 no matter which of the
configured ranges the value came from, and the increment at the end of the loop
was dead. The counter now spans the whole response, like it already did when the
results are not split.

The values of a range were also dereferenced without a check. The sheets API
omits that field for a range that holds nothing, so polling a spreadsheet with an
empty range failed with a NullPointerException.

The exchange building moved to createExchanges so it can be tested without a
Google client, and the branch that reads a whole spreadsheet now marks the
consumer as ready too, like the batch-get branch.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: Andrea Cosentino <ancosen@gmail.com>
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

🌟 Thank you for your contribution to the Apache Camel project! 🌟
🤖 CI automation will test this PR automatically.

🐫 Apache Camel Committers, please review the following items:

  • First-time contributors require MANUAL approval for the GitHub Actions to run
  • You can use the command /component-test (camel-)component-name1 (camel-)component-name2.. to request a test from the test bot although they are normally detected and executed by CI.
  • You can label PRs using skip-tests and test-dependents to fine-tune the checks executed by this PR.
  • Build and test logs are available in the summary page. Only Apache Camel committers have access to the summary.

⚠️ Be careful when sharing logs. Review their contents before sharing them publicly.

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

🧪 CI tested the following changed modules:

  • components/camel-google/camel-google-sheets

🔬 Scalpel shadow comparison — Scalpel: 9 tested, 29 compile-only — current: 9 all tested

Maveniverse Scalpel detected 38 affected modules (current approach: 9).

⚠️ Modules only in Scalpel (29)
  • apache-camel
  • camel-allcomponents
  • camel-catalog
  • camel-catalog-console
  • camel-catalog-lucene
  • camel-catalog-maven
  • camel-catalog-suggest
  • camel-componentdsl
  • camel-csimple-maven-plugin
  • camel-endpointdsl
  • camel-endpointdsl-support
  • camel-itest
  • camel-jbang-core
  • camel-jbang-it
  • camel-jbang-main
  • camel-jbang-plugin-edit
  • camel-jbang-plugin-generate
  • camel-jbang-plugin-kubernetes
  • camel-jbang-plugin-test
  • camel-kamelet-main
  • camel-launcher
  • camel-report-maven-plugin
  • camel-route-parser
  • camel-yaml-dsl
  • camel-yaml-dsl-deserializers
  • camel-yaml-dsl-maven-plugin
  • coverage
  • docs
  • dummy-component

Skip-tests mode would test 9 modules (1 direct + 8 downstream), skip tests for 29 (generated code, meta-modules)

Modules Scalpel would test (9)
  • camel-google-sheets
  • camel-jbang-mcp
  • camel-jbang-plugin-mcp
  • camel-jbang-plugin-route-parser
  • camel-jbang-plugin-tui
  • camel-jbang-plugin-validate
  • camel-launcher-container
  • camel-yaml-dsl-validator
  • camel-yaml-dsl-validator-maven-plugin
Modules with tests skipped (29)
  • apache-camel
  • camel-allcomponents
  • camel-catalog
  • camel-catalog-console
  • camel-catalog-lucene
  • camel-catalog-maven
  • camel-catalog-suggest
  • camel-componentdsl
  • camel-csimple-maven-plugin
  • camel-endpointdsl
  • camel-endpointdsl-support
  • camel-itest
  • camel-jbang-core
  • camel-jbang-it
  • camel-jbang-main
  • camel-jbang-plugin-edit
  • camel-jbang-plugin-generate
  • camel-jbang-plugin-kubernetes
  • camel-jbang-plugin-test
  • camel-kamelet-main
  • camel-launcher
  • camel-report-maven-plugin
  • camel-route-parser
  • camel-yaml-dsl
  • camel-yaml-dsl-deserializers
  • camel-yaml-dsl-maven-plugin
  • coverage
  • docs
  • dummy-component

ℹ️ Shadow mode — Scalpel observes but does not affect test execution. Learn more

All tested modules (38 modules)
  • Camel :: All Components Sync point
  • Camel :: Assembly
  • Camel :: Catalog :: CSimple Maven Plugin (deprecated)
  • Camel :: Catalog :: Camel Catalog
  • Camel :: Catalog :: Camel Report Maven Plugin
  • Camel :: Catalog :: Camel Route Parser
  • Camel :: Catalog :: Console
  • Camel :: Catalog :: Dummy Component
  • Camel :: Catalog :: Lucene (deprecated)
  • Camel :: Catalog :: Maven
  • Camel :: Catalog :: Suggest
  • Camel :: Component DSL
  • Camel :: Coverage
  • Camel :: Docs
  • Camel :: Endpoint DSL
  • Camel :: Endpoint DSL :: Support
  • Camel :: Google :: Sheets
  • Camel :: Integration Tests
  • Camel :: JBang :: Core
  • Camel :: JBang :: Integration tests
  • Camel :: JBang :: MCP
  • Camel :: JBang :: Main
  • Camel :: JBang :: Plugin :: Edit
  • Camel :: JBang :: Plugin :: Generate
  • Camel :: JBang :: Plugin :: Kubernetes
  • Camel :: JBang :: Plugin :: MCP
  • Camel :: JBang :: Plugin :: Route Parser
  • Camel :: JBang :: Plugin :: TUI
  • Camel :: JBang :: Plugin :: Testing
  • Camel :: JBang :: Plugin :: Validate
  • Camel :: Kamelet Main
  • Camel :: Launcher
  • Camel :: Launcher :: Container
  • Camel :: YAML DSL
  • Camel :: YAML DSL :: Deserializers
  • Camel :: YAML DSL :: Maven Plugins
  • Camel :: YAML DSL :: Validator
  • Camel :: YAML DSL :: Validator Maven Plugin

⚙️ View full build and test results

@gnodet gnodet left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Clean, well-tested fix for two real bugs in GoogleSheetsStreamConsumer:

  1. Range index counter bug: AtomicInteger rangeIndex was declared inside the for-loop, so it was re-created on every iteration — always reporting 1. The fix correctly moves it outside the loop.

  2. Null values NPE: The Google Sheets API omits the values field for empty ranges, causing getValues() to return null. The new valuesOf() helper returns List.of() as a safe default.

Bonus fix: forceConsumerAsReady() was missing in the non-range code path (the range-based path was covered by CAMEL-20189 but this branch was missed).

Test coverage is thorough, uses AssertJ, and the extracted createExchanges() method enables clean unit testing without a real Google API client. LGTM.

This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.

Claude Code on behalf of @gnodet

@davsclaus davsclaus added this to the 4.22.0 milestone Aug 7, 2026
@davsclaus davsclaus added the bug Something isn't working label Aug 7, 2026
@davsclaus
davsclaus merged commit f8b8f4f into apache:main Aug 7, 2026
5 checks passed
@oscerd
oscerd requested review from Croway and davsclaus August 7, 2026 07:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants