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

ClientID 不是純英數會造成 panic 及更新 API 到文件 v2.08 版 #7

Open
bestpika opened this issue Apr 27, 2020 · 12 comments
Labels

Comments

@bestpika
Copy link
Contributor

bestpika commented Apr 27, 2020

panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x0 pc=0x8eca9b]

goroutine 1 [running]:
github.com/minchao/go-mitake.parseMessageResponseByPattern(0xa09022, 0x12, 0x279f0240, 0xc000519760, 0x0, 0x0, 0x0)
	d:/tmp/riverland-sms-backend/src/vendor/github.com/minchao/go-mitake/message.go:173 +0x42b
github.com/minchao/go-mitake.parseLongMessageResponse(0x279f0240, 0xc000519760, 0x0, 0x0, 0x0)
	d:/tmp/riverland-sms-backend/src/vendor/github.com/minchao/go-mitake/message.go:193 +0x80
github.com/minchao/go-mitake.(*Client).SendLongMessageBatch(0xc000154050, 0xc000435b80, 0x1, 0x1, 0x0, 0x0, 0x0)
	d:/tmp/riverland-sms-backend/src/vendor/github.com/minchao/go-mitake/api.go:55 +0x591
github.com/minchao/go-mitake.(*Client).SendLongMessage(0xc000154050, 0x0, 0x0, 0xc000422422, 0xa, 0x0, 0x0, 0xc0000b0000, 0x1bb, 0xc000422438, ...)
	d:/tmp/riverland-sms-backend/src/vendor/github.com/minchao/go-mitake/api.go:65 +0x101
main.main()
	d:/tmp/riverland-sms-backend/src/main.go:90 +0x5ef
Process exiting with code: 0
@minchao minchao added the bug label Apr 27, 2020
@bestpika
Copy link
Contributor Author

對了三竹給我的網址是 https://smsapi.mitake.com.tw
我有先 NewClient 然後把裡面的兩個網址換掉

@minchao
Copy link
Owner

minchao commented Apr 27, 2020

印象中是三竹新版的 API,但還我沒測試過 XD

ref minchao/mitake-php#5 (comment)

@bestpika
Copy link
Contributor Author

bestpika commented Apr 28, 2020

@minchao 那你需要文件嗎 XD
不然我晚點對一下改一下再 PR 看看

@minchao
Copy link
Owner

minchao commented Apr 28, 2020

謝謝

引入對 v2 API 支援,可能需考慮對當前 v1 用戶的相容,初步想到有兩種作法:

@bestpika
Copy link
Contributor Author

看來光改 path 沒用
還是得修其他地方

@bestpika
Copy link
Contributor Author

bestpika commented May 21, 2020

我這邊測試的專案修好他了,問題不是簡訊太長,是這裡的 pattern 有問題 (下面是我改完的)

func parseMessageResponse(body io.Reader) (*MessageResponse, error) {
  return parseMessageResponseByPattern(`^\[(.+?)\]$`, body)
}

因為不是大家都用數字當 ClientID (我用 uuid)
然後因為他沒抓到東西所以導致這段沒執行

if matched, _ := regexp.MatchString(pattern, text); matched {
  result = new(MessageResult)
  response.Results = append(response.Results, result)
}

才會造成他在填資料的時候那個目標 <nil> 導致 panic

@minchao
Copy link
Owner

minchao commented May 21, 2020

@bestpika 謝謝,可以麻煩您協助 PR 修正嗎?😃

@bestpika
Copy link
Contributor Author

@minchao 等我測完確定都沒問題再一起弄上去

@bestpika bestpika changed the title Golang v1.14.2 訊息過長使用 SendLongMessage 會 panic ClientID 不是數字會造成 panic May 21, 2020
@bestpika bestpika changed the title ClientID 不是數字會造成 panic ClientID 不是純英數會造成 panic May 21, 2020
@bestpika
Copy link
Contributor Author

@minchao 我想問一下你之前參考的文件是幾版的?
或者可以提供給我對照一下

@minchao
Copy link
Owner

minchao commented May 22, 2020

@bestpika v1.98, email?

@bestpika
Copy link
Contributor Author

@minchao 我發現問題在哪了,我昨天只有改長簡訊
但實際上現在不是分長短簡訊,而是分單筆或多筆簡訊,所以單筆的 batch 會有問題

@bestpika
Copy link
Contributor Author

我分兩段,先把那個 panic 修掉
然後再弄個 v2

@bestpika bestpika changed the title ClientID 不是純英數會造成 panic ClientID 不是純英數會造成 panic 及更新 API 到文件 v2.08 版 May 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants