DataBuffer must have getOffsets().length equal to 1 or numBands

Hello, everybody.

I am looking into a group of similar bugs, returning this error:

DataBuffer must have getOffsets().length equal to 1 or numBands.

@jive We’ve shortly discussed this one at foss4g europe 2026

I can trigger it in our geoserver, but it is unclear if this is a geoserver, geotools or imagen problem. It seems to be a regression introduced when imagen appeared. (We know the same geoserver URL used to work in the past)

This seems the same issue:

and here is one of the reports:

It happens if you:

I have stumbled upon a sort of nasty workaround: I noticed it working for some data files but not others, and the difference is here:

When triggerCopyOperations is true, a copy is made of the raster, which sets databuffer.banks to 1. So I can change the code to this:

this.triggerCopyOperation = (source.getSampleModel() instanceof SinglePixelPackedSampleModel
                || source.getSampleModel() instanceof ComponentSampleModelImageN)
        && bandIndices.length < 3;

Unfortunately, I am seriously lacking in knowledge for all this and can’t tell which step in the whole chain of events is wrong. So if anyone has some advice around how to proceed, I’d like to hear it.

  • I can make a PR of the triggerCopyOperations thing. The original seems strange to me, as the 3 suggests RGB, but my bands are 2 unrelated grayscale images. So this might fix more than expected. We will probably do some copying sometimes when we should not if we go this way. I can of course check some system property.

  • Near that line is a flag DATABUFFER_WORKAROUND which seems to have similar purposes. Maybe here is something missing? The fact that numbands and databuffer.banks differ seems strange to me.

  • Or I can try and trace this further, but I would welcome a push in the right direction from someone knowledgeable, e.g.
    a) which one is correct: banks=2 (source perspective) or numbands=1 (destination prspective)
    b) what knowledge does rft represent that is not available in raster?
    c) How to decide which project geoserver/geotools/imagen is in error here?