Skip to content

Conversation

@mpkorstanje
Copy link
Contributor

@mpkorstanje mpkorstanje commented Sep 9, 2025

⚡️ What's your motivation?

In Cucumber JVM attachments can be created in a few different ways. How influences whether the attachment ends up as elements of embeddings or output.

Method Encoding Media Type Destination
Scenario.attach(byte[], ...) BASE64 any, from method embeddings
Scenario.attach(String, ...) IDENTITY any, from method embeddings
Scenario.log(String) IDENTITY text/x.cucumber.log+plain output

Originally the implementation determined the destination based on the encoding, but this is obviously not correct. An alternative would be to select on the media type.

This does come with the disadvantage that Scenario.attach also takes in a media type argument. So in theory that could be text/x.cucumber.log+plain but for now we'll assume that is not the case.

Should this assumption prove wrong we could match on both encoding and media type, but it would be more reasonable for the user to change their code.

Fixes: cucumber/cucumber-jvm#3069

🏷️ What kind of change is this?

  • 🐛 Bug fix (non-breaking change which fixes a defect)

♻️ Anything particular you want feedback on?

If you are using text/x.cucumber.log+plain in combination with Scenario.attach please let us know your use case.

📋 Checklist:

  • I agree to respect and uphold the Cucumber Community Code of Conduct
  • I've changed the behaviour of the code
    • I have added/updated tests to cover my changes.
  • My change requires a change to the documentation.
    • I have updated the documentation accordingly.
  • Users should know about my change
    • I have added an entry to the "Unreleased" section of the CHANGELOG, linking to this pull request.

In Cucumber JVM attachments can be created in a few different ways. How
influences whether the attachment ends up as elements of `embeddings` or
`output`.

| Method                         | Encoding | Media Type                | Destination  |
| ------------------------------ | -------- | ------------------------- | ------------ |
| `Scenario.attach(byte[], ...)` | BASE64   | any, from method          | `embeddings` |
| `Scenario.attach(String, ...)` | IDENTITY | any, from method          | `embeddings` |
| `Scenario.log(String)`         | IDENTITY | text/x.cucumber.log+plain | `output`     |

Originally the implementation determined the destination based on the
encoding, but this is obviously not correct. An alternative would be to
select on the media type.

This does come with the disadvantage that `Scenario.attach` also takes
in a media type argument. So in theory that could be
`text/x.cucumber.log+plain` but for now we'll assume that is not the
case.

Should this assumption prove wrong we could match on both encoding and
media type, but it would be more reasonable for the user to change their
code.

Fixes: cucumber/cucumber-jvm#3069
@mpkorstanje mpkorstanje force-pushed the fix-attachment-rendering branch from 30c344c to b1eec04 Compare September 9, 2025 02:04
@mpkorstanje mpkorstanje marked this pull request as ready for review September 9, 2025 02:05
@mpkorstanje mpkorstanje merged commit fbd69d5 into main Sep 9, 2025
5 checks passed
@mpkorstanje mpkorstanje deleted the fix-attachment-rendering branch September 9, 2025 02:06
mpkorstanje added a commit that referenced this pull request Sep 9, 2025
While the compatibility already contains samples with attachments it is
also useful to have these in the regression set against Cucumber-JVM
7.26 should there be other attachment related bugs in the future.

This complements #12.
mpkorstanje added a commit that referenced this pull request Sep 9, 2025
While the compatibility already contains samples with attachments it is
also useful to have these in the regression set against Cucumber-JVM
7.26 should there be other attachment related bugs in the future.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

JSON structure of non-binary attachments changed in 7.28.0

2 participants