Comments (7)
Given where the error is originating has no concept of what header it is trying to parse, I don't think it's worth it to change the error string. This should be a 400 though.
from talaria.
@denopink did you still need my help?
from talaria.
@renaz6 looks like we still get a 500 with the current talaria repo using github.com/xmidt-org/wrp-go/v3 v3.1.1
locally and with the latest image docker run -p 6200-6204:6200-6204 xmidt/talaria:latest
(re-pulled the image to make sure)
from talaria.
@ilawjr hey Ivan, can you help me test/verify this issue? 🧑🔬
I'm seeing the 500 locally atm.
from talaria.
This issue was fixed in WRP-Go v3.1.1 and Talaria v0.6.4. @denopink could you verify the Talaria version you are using locally?
from talaria.
@renaz6 looks like it should have been the latest
. Let me redeploy locally and confirm.
from talaria.
tl;rd
func NewEntityResponseWriter(defaultFormat wrp.Format) ResponseWriterFunc {
return func(httpResponse http.ResponseWriter, wrpRequest *Request) (ResponseWriter, error) {
format, err := DetermineFormat(defaultFormat, wrpRequest.Original.Header, "Accept")
if err != nil {
return nil, err
}
...
}
}
to
func NewEntityResponseWriter(defaultFormat wrp.Format) ResponseWriterFunc {
return func(httpResponse http.ResponseWriter, wrpRequest *Request) (ResponseWriter, error) {
format, err := DetermineFormat(defaultFormat, wrpRequest.Original.Header, "Accept")
if err != nil {
wrappedErr := httpError{
err: err,
code: http.StatusBadRequest,
}
return nil, wrappedErr
}
...
}
}
Explanation
Looked into it and it looks like we're not handling a bad format error from DetermineFormat
at
https://github.com/xmidt-org/wrp-go/blob/4b275411c7aa52e1a537cc130f3b0f37e526c978/wrphttp/requestResponse.go#L140-L143
func NewEntityResponseWriter(defaultFormat wrp.Format) ResponseWriterFunc {
return func(httpResponse http.ResponseWriter, wrpRequest *Request) (ResponseWriter, error) {
format, err := DetermineFormat(defaultFormat, wrpRequest.Original.Header, "Accept")
if err != nil {
return nil, err
}
...
}
}
Then NewEntityResponseWriter
s DetermineFormat error
gets handled as a 500
at
https://github.com/xmidt-org/wrp-go/blob/4b275411c7aa52e1a537cc130f3b0f37e526c978/wrphttp/handler.go#L134-L138
func (wh *wrpHandler) ServeHTTP(httpResponse http.ResponseWriter, httpRequest *http.Request) {
...
wrpResponse, err := wh.newResponseWriter(httpResponse, wrpRequest)
if err != nil {
wh.errorEncoder(wrpRequest.Context(), err, httpResponse)
return
}
...
}
Tested locally with a quick patch and it looks goods:
curl -v --location --request POST 'localhost:6200/api/v3/device/send' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic dXNlcjpwYXNz' \
--data-raw '{
"msg_type":3,
"content_type":"application/json",
"source":"dns:me",
"dest":"mac:112233445566",
"transaction_uuid":"1234567890",
"payload":"eyJjb21tYW5kIjoiR0VUIiwibmFtZXMiOlsiU29tZXRoaW5nIl19",
"partner_ids":["comcast"]
}'
# Output:
Note: Unnecessary use of -X or --request, POST is already inferred.
* Trying 127.0.0.1:6200...
* Connected to localhost (127.0.0.1) port 6200 (#0)
> POST /api/v3/device/send HTTP/1.1
> Host: localhost:6200
> User-Agent: curl/7.79.1
> Accept: */*
> Content-Type: application/json
> Authorization: Basic dXNlcjpwYXNz
> Content-Length: 223
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 400 Bad Request
< Content-Length: 29
< Content-Type: text/plain; charset=utf-8
< X-Talaria-Build: 0.1.4
< X-Talaria-Flavor: mint
< X-Talaria-Region: east
< X-Talaria-Server: talaria
< X-Talaria-Start-Time: 26 Apr 22 15:51 UTC
< Date: Tue, 26 Apr 2022 16:03:41 GMT
<
* Connection #0 to host localhost left intact
Invalid WRP content type: */*%
#
from talaria.
Related Issues (20)
- Feature: Echoing additional Device wrp fields in qos ack
- CVE-2022-41723 (High) detected in golang.org/x/net-v0.4.0 - autoclosed HOT 1
- Talaria should provide a metric showing the maxDevices HOT 1
- Update Candlelight to v0.0.16 HOT 1
- Update Tracing Configurations
- Talaria drain job should provide an ability to drop specific devices. HOT 2
- Add Bascule Helper Package
- CVE-2023-2816 (High) detected in github.com/hashicorp/Consul/api-v1.20.0 - autoclosed HOT 1
- Update Candlelight Version for Tracing
- Unauthorised device connect /api/v2/device route HOT 11
- Use TrustClaim to determine whether to replace a connected device or not
- (unify) Use SPDX for copyright and reuse.
- (unify) Update code style.
- Add new metric to determine client connection issues
- talaria.yaml uses incorrect inbound timeout key HOT 1
- docs: verify example talaria config
- Issue in docker build? HOT 2
- add xdmit-timestamp metadata field to every message HOT 1
- investigate absence of interfaced-used field HOT 1
- make build with talaria HOT 3
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 talaria.