`ProductImage::resolve` panics on some product versions

Open Beginner friendly
#1,330 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
kubernetes, rust

Research direction

Start at crates/stackable-operator/src/commons/product_image_selection.rs:333 and compare its truncation with utils/length_enforcement.rs and the existing truncate_at_char_boundary method. Reproduce with the supplied KafkaCluster manifest, whose product version triggers a panic at a UTF-8 character boundary. Done means resolving that version no longer panics and the operator can continue reconciling.

Written by the indexing model from the issue text.

Description

scheduled-for/27.3.0

https://github.com/stackabletech/operator-rs/blob/b0b8ca31a79da03b3fa20507b709390d2647efe4/crates/stackable-operator/src/commons/product_image_selection.rs#L333

That uses truncate which panics when the new_len doesn't fall on a char boundary.

`product_image_selection.rs:333:31` (`assertion failed: self.is_char_boundary(new_len)`), `main` exits via `JoinError::Panic`

A fix could/would be to use truncate(formatted.floor_char_boundary(LABEL_VALUE_MAX_LEN)), as utils/length_enforcement.rs already does, or reject non-ASCII versions and tags. And I actually see that we have a truncate_at_char_boundary method as well but it's private right now.

The problem here is that a single "bad" CR kills the entire operator and no other thing reconciles.

To reproduce:

# productVersion: 40 x U+00E9 (two bytes each), so byte 63 falls inside a character.
apiVersion: kafka.stackable.tech/v1alpha1
kind: KafkaCluster
metadata:
  name: bad-version
spec:
  image:
    productVersion: "éééééééééééééééééééééééééééééééééééééééé"
  clusterConfig:
    metadataManager: KRaft
  controllers:
    roleGroups:
      default:
        replicas: 1
  brokers:
    roleGroups:
      default:
        replicas: 1
Dominant language
Rust
Stars
170
Forks
20
Avg merge
1d 10h
Merged PRs (30d)
17

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from stackabletech/operator-rs

All issues in stackabletech/operator-rs

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.