# Bug OP-16585 - Search produces 500 error response on certain attachment constellation

Project: OpenProject
Status: closed
URL: https://community.openproject.org/work_packages/OP-16585

## Open points

_No work packages_

## Details

| Attribute | Value |
| --- | --- |
| Date |  |
| Priority | Medium |
| Module |  |
| Target versions | 15.3.0 |
| Observed in versions |  |
| Sprint | 15.3.0 |
| Backlog bucket |  |
| Bug found in version (deprecated) |  |
| Found in mobile app version |  |
| Follow-up feedback e-mail |  |
| Requires doc change | No |
| Accessibility | No |
| Pull preview |  |
| List |  |
| Labels |  |

## People

| Attribute | Value |
| --- | --- |
| Assignee |  |
| Accountable | Jens Ulferts |
| Product manager |  |
| Developers |  |
| Designer |  |
| Ordered by |  |
| Signed off by |  |
| Interest by |  |

## Planning

| Attribute | Value |
| --- | --- |
| Relevance |  |

## Costs

| Attribute | Value |
| --- | --- |
| Votes |  |
| Work |  |
| Labor costs |  |

## Description

### Steps to reproduce

1.  Have a work package

2.  The work package has two attachments
    
    1.  The first attachment has a `fulltext` property that is empty meaning it is e.g. an attachment that is not parsed or one that does not produce text when it is parsed
    
    2.  The first attachment has a `fulltext` property that is not empty meaning it is e.g. an image or an XLS with text in it. The text needs to be longer, e.g.  "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled"

3.  Search for text that is included in the `fulltext` property of the second attachment. The text needs to be non consecutive in the text searched against, e.g. "simply standard unknown"

4.  Go to the "All" tab in the search results

### What is the buggy behavior?

  - A 500 is returned

### What is the expected behavior?

1.  The search result is displayed with the matched text highlighted

### Notes

The problem comes from a [line in the search helper](https://github.com/opf/openproject/blob/df69d59cfe7ccc3b62b28c4c4627186183a590a7/app/helpers/search_helper.rb#L127) that returns   
`[nil, "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled"].join(" ")`  
which will result in an `US-ASCII` encoding not compatible with `Commonmarker`.
