# Bug JIM-250 - Jira API logging fails with Encoding::CompatibilityError

Project: Stream Jira to OpenProject data Migrator
Status: closed
URL: https://community.openproject.org/work_packages/JIM-250

## Open points

_No work packages_

## Details

| Attribute | Value |
| --- | --- |
| Date |  |
| Priority | Medium |
| Module | Integrations / Jira |
| Target versions | 18.0.0 |
| Observed in versions | 17.9.1 |
| Sprint | Sprint 18.11.-24.11.2026 |
| Backlog bucket |  |
| Bug found in version (deprecated) |  |
| Requires doc change | No |
| Accessibility | No |
| Pull preview |  |
| List |  |
| Labels |  |

## People

| Attribute | Value |
| --- | --- |
| Assignee |  |
| Accountable |  |
| Product manager |  |
| Developers | Alfonso Mancilla |
| 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 an API error, e.g. &quot;User not found&quot;
    

### What is the buggy behavior?

*   An exception stops the import
    

### What is the expected behavior?

1.  Import is not stopped
    
2.  API error is logged
    

### **Logs**

```text
Encoding::CompatibilityError: incompatible character encodings: UTF-8 and BINARY (ASCII-8BIT)
app/workers/import/jira_fetch_users_job.rb:157:in 'Import::JiraFetchUsersJob#build_user_upsert_data'
app/workers/import/jira_fetch_users_job.rb:132:in 'block in Import::JiraFetchUsersJob#build_users_upsert_data'
app/workers/import/jira_fetch_users_job.rb:131:in 'Array#each'
app/workers/import/jira_fetch_users_job.rb:131:in 'Enumerable#filter_map'
app/workers/import/jira_fetch_users_job.rb:131:in 'Import::JiraFetchUsersJob#build_users_upsert_data'
app/workers/import/jira_fetch_users_job.rb:41:in 'Import::JiraFetchUsersJob#perform'
app/workers/shared_job_setup.rb:59:in 'block in SharedJobSetup#prepare_job_context'
app/workers/shared_job_setup.rb:76:in 'SharedJobSetup#with_clean_request_store'
app/workers/shared_job_setup.rb:55:in 'SharedJobSetup#prepare_job_context'
```

### Analysis

1.  Net::HTTP hands back response bodies as ASCII-8BIT (it never applies the charset from Content-Type). So in app/services/import/jira\_client.rb:408, response\_body: response.body.to\_s is binary.
    
2.  ApiError#to\_s (jira\_client.rb:72) interpolates that body into a UTF-8 literal:  
    &quot;#{super}. STATUS: #{@status} RESPONSE\_BODY: #{@response\_body} ...&quot;  
    &nbsp; This does not raise, because the literal parts and the I18n message are ASCII-only - Ruby considers an ASCII-only UTF-8 string compatible with BINARY and quietly returns a BINARY result. So e.message is a binary string carrying raw UTF-8 bytes (Jira&#x27;s localized error text, a user&#x27;s name with an umlaut, an HTML error page, etc.).
    
3.  jira\_fetch\_users\_job.rb:157 then does:  
    Rails.logger.error &quot;Error fetching user data for user key #{jira\_user\_key}: #{e.message}&quot;  
      jira\_user\_key comes from JSON.parse, so it is UTF-8. If the key contains a non-ASCII character (older Jira uses the username as the key, so jöhn is possible), you now mix non-ASCII UTF-8 with non-ASCII BINARY - incompatible, Encoding::CompatibilityError.
    

If the user key were pure ASCII it would silently succeed and just log mojibake, which is why this only blows up for some users. The raise on line 160 has the same defect, and so does every other site that interpolates ApiError#message (resolve\_mention\_user\_keys:88, for instance).

### Environment information

**OpenProject installation type**

*   All
    

**OpenProject version**

*   v17.9
    

**Browser**

*   All
    

**Operating System**

*   All
    

**Language**

*   All
