Skip to content

Conversation

@kentoyoshida
Copy link

Summary

  • Fix an error that occurs when JQL queries contain Japanese characters
  • The issue was caused by StringEntity defaulting to ISO-8859-1 encoding instead of UTF-8
  • Explicitly specify UTF-8 encoding to properly handle Japanese and other multibyte characters

Problem

When using Japanese characters in JQL queries (e.g., labels="テスト"), the following error occurred:

Error: Could not guess schema due to empty data set

However, the same query works correctly when using curl with --data-urlencode option.

Root Cause

In JiraClient.java:228, the StringEntity constructor was called without specifying character encoding:

request.setEntity(new StringEntity(body));

Apache HttpClient 4.x defaults to ISO-8859-1 encoding when no encoding is specified, which causes Japanese characters to be incorrectly encoded when sent to the JIRA API.

This issue was introduced in commit 2692818 "use new jql search API (#6)" when the implementation was changed to use POST requests with JSON body instead of GET requests with query parameters.

Changes

Modified Files

  • src/main/java/org/embulk/input/jira/client/JiraClient.java

    • Added StandardCharsets import
    • Changed new StringEntity(body) to new StringEntity(body, StandardCharsets.UTF_8)
  • src/test/java/org/embulk/input/jira/client/JiraClientTest.java

    • Added test case test_searchIssues_withJapaneseJql() to verify Japanese JQL queries work correctly
  • src/test/resources/jira_client.json

    • Added test data for Japanese JQL query test case

Testing

  • ✅ All existing tests pass
  • ✅ New Japanese JQL query test case passes
  • ✅ Verified UTF-8 encoding in compiled bytecode using javap

🤖 Generated with Claude Code

kentoyoshida and others added 2 commits October 15, 2025 07:52
Fix an error that occurs when JQL queries contain Japanese characters

## Problem
- Error occurs when JQL contains Japanese characters (e.g., `labels="テスト"`)
- Error message: "Could not guess schema due to empty data set"
- Works correctly with curl command using `--data-urlencode`

## Root Cause
- StringEntity in JiraClient.java was created without explicit encoding
- Defaulted to ISO-8859-1, causing Japanese characters to be incorrectly encoded

## Changes
- Explicitly specify UTF-8 encoding in StringEntity constructor
- Add test case for Japanese JQL queries

## Testing
- All existing tests pass
- Japanese JQL query test case passes

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Explicitly specify UTF-8 charset in Content-Type header to ensure
the server correctly interprets the request body encoding.

This complements the StringEntity UTF-8 encoding fix by informing
the server that the request body is UTF-8 encoded.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@kentoyoshida kentoyoshida force-pushed the fix/issue-38462-jql-japanese-encoding branch from 2263a13 to e1b602f Compare October 15, 2025 08:47
@kentoyoshida kentoyoshida marked this pull request as ready for review October 15, 2025 08:49
Copy link

@yas-okadatech yas-okadatech left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@kentoyoshida kentoyoshida merged commit c0aaad1 into master Oct 15, 2025
3 checks passed
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.

2 participants