Comments (11)
🤖
Hey there @CaoYan1! 🖐️
I'm Dosu, a friendly bot here to help you out while waiting for a human maintainer. I'm your go-to for solving bugs, answering questions, and helping you become the best contributor you can be! 🚀
Just wanted to say hi and let you know I'm here for you. Hang tight, we'll get through your issue together! 💪😀
Based on the information you've provided, it seems like you're encountering an issue where the form.EncodeValues(msg)
function is returning an error when it encounters a repeated custom message in your request, causing the rest of the fields to be ignored.
This behavior is due to how the form.EncodeValues(msg)
function handles unsupported field types. When it encounters an unsupported field type, it returns an error and stops processing the rest of the fields. This is why your id
field is being ignored. You can see this in the encodeMessage
function in the encoding/form/proto_encode.go file:
func encodeMessage(msgDescriptor protoreflect.MessageDescriptor, value protoreflect.Value) (string, error) {
// ...
default:
return "", fmt.Errorf("unsupported message type: %q", string(msgDescriptor.FullName()))
}
}
However, I found a similar issue in the Kratos repository that was resolved: 当message中有自定义list消息且url中有参数时,使用生成的http client无法生成正确的url. This issue was addressed in the following pull request: 修复地址栏参数.
Based on this, it seems like the Kratos team has made some changes to handle this scenario. I recommend checking out these resources to see if they can help resolve your issue. If you're still encountering problems, could you please provide more details about your use case and the exact error message you're seeing? This will help me better understand the issue and provide a more accurate solution.
Sources
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.
Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.
If you want to continue the conversation, start your reply with @dosu-bot.
from kratos.
😭 I'm busy now.
from kratos.
My Kratos
version is latest(2.7.2) and doesn't work still
from kratos.
Can you provide your http client code? I try to reproduce your case, but there was no issue found.
Here is my reproduce repo.
# send http request
curl http://localhost:8000/my-api/1 -X POST -H 'Content-Type: application/json' -d '{"msg":[{}]}'
# console
id:"1" msg:{}
from kratos.
Based on your repo, you can try this code. I can reproduce this issue. @kvii
func TestHttpClient(t *testing.T) {
client, _ := http.NewClient(context.Background(), http.WithEndpoint("localhost:8000"))
c := NewMyServiceHTTPClient(client)
resp, err := c.Call(context.Background(), &Request{
Id: "id",
Msg: []*MsgInline{
{},
},
})
// will return 404 error
fmt.Println(resp, err)
}
from kratos.
Oh, this is an issue of kratos http client, not server. I pushed a commit to my repo, add tests for this issue at here.
Source codes:
- Generated http client side code in my reproduce repo:
- Codes in
binding.EncodeURL
:
kratos/transport/http/binding/encode.go
Lines 15 to 19 in 34d9666
from kratos.
Cool! Do you have a plan to fix it?
from kratos.
I'd like to help you.
from kratos.
I've created a PR for this issue. But the code style is terrible.
from kratos.
这个问题 #2805 应该是解决了的
from kratos.
Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑🤝🧑👫🧑🏿🤝🧑🏻👩🏾🤝👨🏿👬🏿
This issue https://github.com/go-kratos/kratos/pull/2805 should be solved
from kratos.
Related Issues (20)
- [Feature] consule register need suport tags[] HOT 2
- When the App stops, the ctx in the afterStop callback is not available HOT 3
- [Question] How to return other Status Code in a successful HTTP request? HOT 7
- [Feature] Add Unwrap to custom response writer. HOT 3
- [Proposal] config feature roadmap HOT 22
- [Feature] replace kratos metrics with otel metrics HOT 3
- [The modification of header file information of http response does not take effect] ctx.Header().Set("Content-Type", "application/octet-stream") HOT 5
- [Question] How to return a custom response json? HOT 1
- Package version dependency issue HOT 4
- go generate ./...failed HOT 5
- [Feature]Add svrType related fields in proto to protoc-gen-go-http and http transport HOT 3
- proto file used to build the api document reported an error HOT 1
- consul watch, the server is offline and will not receive any notification HOT 6
- [Feature] Add NewClient method to gRPC Client HOT 3
- [Question] DDD的最佳实践方式?包括CQRS、Clean Architecture、六边形结构 HOT 5
- [Question]请教下kratos如何定义支持上传文件接口? HOT 2
- metrics statistics and usage issues [Question] HOT 5
- `stream` response in proto failed to generate http client HOT 5
- [Feature] Add kratos errors to buf remote plugin HOT 1
- [Question] I modified it based on examples/helloworld and found that client/main.go reported an error when executing. I am not sure if it is a BUG. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kratos.