Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix add watcher invalid payload issue #338

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

djx339
Copy link

@djx339 djx339 commented Nov 12, 2024

Currently, when creating a Jira "Add Watcher" request, the username in playload has been converted from a string type to a []byte type. This change causes the JSON-encoded result is not the username, leading to request failure. Here’s an example. https://go.dev/play/p/pBiwq2t2bNl

package main

import (
	"bytes"
	"encoding/json"
	"fmt"
)

func main() {
	accountID := "someuser"

	buf1 := new(bytes.Buffer)
	if err := json.NewEncoder(buf1).Encode(accountID); err != nil {
		panic(err)
	}
	fmt.Println(buf1)

	buf2 := new(bytes.Buffer)
	if err := json.NewEncoder(buf2).Encode([]byte(accountID)); err != nil {
		panic(err)
	}
	fmt.Println(buf2)
}

output

"someuser"

"c29tZXVzZXI="

@djx339 djx339 force-pushed the fix-jira-add-watcher-payload-error branch from 6ae33ba to cb9ba4a Compare November 12, 2024 02:28
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.

1 participant