Closed kissen closed 4 years ago
Awesome bug report! Thanks a ton for documenting all of this.
Also, if you have a fediverse account, please do reach out to me at @cj@mastodon.technology
. I would love to learn more about your experience using this library. Especially as I am actively updating https://go-fed.org.
Hi @kissen
With the latest merge, can you confirm if this issue is fixed for you?
Yes, this fixes the bug from what I can tell. Thank you!
(Unfortunately I don't really have time to work on any ActiviyPub projects this summer, but maybe I'll look into it again later. I certainly continue to be interested in it.)
I'm currently playing around with with go-fed, in particular with the social API. Having set up an actor with
pub.NewActor
and a handler withpub.NewActivityStreamsHandler
, I try to post the following JSON taken from the ActivityPub documentation to a users outbox.Seems like go-fed correctly tries to wrap the
Note
into aCreate
, but doing so I get anil
dereference error inactivity/pub/util.go
in line 284. Full stack trace further down.How your code uses this library: Currently I have a bare-bones implementation of the social protocol. You can look at the code here if you want.
What troubleshooting has already been tried: As a workaround/fix(?) I find that checking all properties for
nil
inwrapInCreate
gets rid of the panic.activityTo := streams.NewActivityStreamsToProperty()
to := v.GetActivityStreamsTo()
for iter := to.Begin(); iter != to.End(); iter = iter.Next() {
var id *url.URL
id, err = ToId(iter)
if err != nil {
return
if to := v.GetActivityStreamsTo(); to != nil {
activityTo := streams.NewActivityStreamsToProperty()
for iter := to.Begin(); iter != to.End(); iter = iter.Next() {
var id *url.URL
id, err = ToId(iter)
if err != nil {
return
}
activityTo.AppendIRI(id) }
activityTo.AppendIRI(id)
c.SetActivityStreamsTo(activityTo) }
c.SetActivityStreamsTo(activityTo) } if v, ok := o.(btoer); ok {
activityBto := streams.NewActivityStreamsBtoProperty()
bto := v.GetActivityStreamsBto()
for iter := bto.Begin(); iter != bto.End(); iter = iter.Next() {
var id *url.URL
id, err = ToId(iter)
if err != nil {
return
if bto := v.GetActivityStreamsBto(); bto != nil {
activityBto := streams.NewActivityStreamsBtoProperty()
for iter := bto.Begin(); iter != bto.End(); iter = iter.Next() {
var id *url.URL
id, err = ToId(iter)
if err != nil {
return
}
activityBto.AppendIRI(id) }
activityBto.AppendIRI(id)
c.SetActivityStreamsBto(activityBto) }
c.SetActivityStreamsBto(activityBto) } if v, ok := o.(ccer); ok {
activityCc := streams.NewActivityStreamsCcProperty()
cc := v.GetActivityStreamsCc()
for iter := cc.Begin(); iter != cc.End(); iter = iter.Next() {
var id *url.URL
id, err = ToId(iter)
if err != nil {
return
if cc := v.GetActivityStreamsCc(); cc != nil {
activityCc := streams.NewActivityStreamsCcProperty()
for iter := cc.Begin(); iter != cc.End(); iter = iter.Next() {
var id *url.URL
id, err = ToId(iter)
if err != nil {
return
}
activityCc.AppendIRI(id) }
activityCc.AppendIRI(id)
c.SetActivityStreamsCc(activityCc) }
c.SetActivityStreamsCc(activityCc) } if v, ok := o.(bccer); ok {
activityBcc := streams.NewActivityStreamsBccProperty()
bcc := v.GetActivityStreamsBcc()
for iter := bcc.Begin(); iter != bcc.End(); iter = iter.Next() {
var id *url.URL
id, err = ToId(iter)
if err != nil {
return
if bcc := v.GetActivityStreamsBcc(); bcc != nil {
activityBcc := streams.NewActivityStreamsBccProperty()
for iter := bcc.Begin(); iter != bcc.End(); iter = iter.Next() {
var id *url.URL
id, err = ToId(iter)
if err != nil {
return
}
activityBcc.AppendIRI(id) }
activityBcc.AppendIRI(id)
c.SetActivityStreamsBcc(activityBcc) }
c.SetActivityStreamsBcc(activityBcc) } if v, ok := o.(audiencer); ok {
activityAudience := streams.NewActivityStreamsAudienceProperty()
aud := v.GetActivityStreamsAudience()
for iter := aud.Begin(); iter != aud.End(); iter = iter.Next() {
var id *url.URL
id, err = ToId(iter)
if err != nil {
return
if aud := v.GetActivityStreamsAudience(); aud != nil {
activityAudience := streams.NewActivityStreamsAudienceProperty()
for iter := aud.Begin(); iter != aud.End(); iter = iter.Next() {
var id *url.URL
id, err = ToId(iter)
if err != nil {
return
}
activityAudience.AppendIRI(id) }
activityAudience.AppendIRI(id)
c.SetActivityStreamsAudience(activityAudience) }
c.SetActivityStreamsAudience(activityAudience) } return }
Any shareable logs of observations: Here is the full stacktrace.
Resulting impact of the defective behavior: Posting a plain
Note
into a users outbox results in that request panicking.Please Describe The Expected Behavior I expect the
Note
to be properly wrapped in aCreate
without anil
reference.