# C2S/S2S Update Issues

**URL:** <https://socialhub.activitypub.rocks/t/c2s-s2s-update-issues/3425>\
**Category:** ActivityPub\
**Created:** [July 18, 2023, 10:36pm UTC](https://socialhub.activitypub.rocks/t/c2s-s2s-update-issues/3425 "2023-07-18T22:36:26Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![stevebate](https://socialhub.activitypub.rocks/user_avatar/socialhub.activitypub.rocks/stevebate/32/2763_2.png) [@stevebate](https://socialhub.activitypub.rocks/u/stevebate)\
**Post date:** [July 18, 2023, 10:36pm UTC](https://socialhub.activitypub.rocks/t/c2s-s2s-update-issues/3425/1 "2023-07-18T22:36:27Z")

</div>

Continued from [Stricter specifications for pagination of Collections and OrderedCollections - ActivityPub / Client to Server - SocialHub](https://socialhub.activitypub.rocks/t/stricter-specifications-for-pagination-of-collections-and-orderedcollections/2633/16)

> [@Stricter specifications for pagination of Collections and OrderedCollections](https://socialhub.activitypub.rocks/t/stricter-specifications-for-pagination-of-collections-and-orderedcollections/2633/17):
>
> > [@Stricter specifications for pagination of Collections and OrderedCollections](https://socialhub.activitypub.rocks/t/stricter-specifications-for-pagination-of-collections-and-orderedcollections/2633/14):
> >
> > In the second example, the IRI “[https://example.test/object-1”](https://example.test/object-1%E2%80%9D) is associated with two _different_ objects: the one in the Update activity and the existing object
> 
> But both objects have the same set of properties, which is why it’s not two “different” objects, it’s just that one document represents only a subset of the properties that one object has, which is completely valid.

In the example I referenced, the two objects definitely don’t have the same set of properties or the same values for those properties. Given an existing Note:

```json
  {
    "@context": "https://www.w3.org/ns/activitystreams",
    "id": "https://example.test/note-1",
    "type": "Note",
    "content": "Hello",
    "summary": "A greeting."
  },

```

The “id” property (an alias of JSON-LD “@id”) is the unique URI of a specific object/resource, a Note in this case.

And given a C2S Update activity for that Note:

```json
  {
    "@context": "https://www.w3.org/ns/activitystreams",
    "id": "https://example.test/update-1",
    "type": "Update",
    "object": {
      "id": "https://example.test/note-1",
      "content": "Howdy",
      "name": "greeting-note",
      "summary": null
    }
  }

```

This is a graph with two resources. The first resource is an Update activity. The activity resource references a second resource via the “object” property. The second resource is a… I’m going to call it an _update description_. It has instructions about how to update the existing Note. In this case, it is instructing the server to modify the “content” property, add the “name” property and delete the “summary” property.

The second resource (the update description) also has an “id” property, which means that’s the URI of that resource. But, of course, it’s not. It’s the URI of the update’s target object. That’s the first problem. I’m suggesting that an activity “target” property should be used for this purpose instead. The update description resource probably doesn’t even need an “id” in most cases. It could be referenced via an RDF blank node.

The second issue is that AP requires all objects to have a “type” property. I left that out of the example intentionally since there is no AP-defined type for an update description (and an extension didn’t feel necessary for the example). Putting “Note” in the type property (JSON-LD “@type”) is not correct. It’s not a Note, it’s an update description.

The third issue is the null value for “summary”. The AP specification says this should be interpreted as a property deletion instruction. However, that doesn’t play well with JSON-LD.

> A [map entry](https://infra.spec.whatwg.org/#map-entry) in the body of a [JSON-LD document](https://www.w3.org/TR/json-ld11/#dfn-json-ld-document) whose value is `null` has the same meaning as if the [map entry](https://infra.spec.whatwg.org/#map-entry) was not defined.

The JSON-LD parsers I’ve experimented with (including the [JSON-LD Playground](https://json-ld.org/playground/#startTab=tab-expanded&json-ld=%7B%22%40context%22%3A%22https%3A%2F%2Fwww.w3.org%2Fns%2Factivitystreams%22%2C%22id%22%3A%22https%3A%2F%2Fexample.test%2Fupdate-1%22%2C%22type%22%3A%22Update%22%2C%22object%22%3A%7B%22id%22%3A%22https%3A%2F%2Fexample.test%2Fnote-1%22%2C%22content%22%3A%22Howdy%22%2C%22name%22%3A%22greeting-note%22%2C%22summary%22%3Anull%7D%7D)) do indeed strip out the null-valued instruction from the expanded Update activity (the “summary” property is dropped).

The fourth issue occurs when the Update subgraph is merged with the existing AP graph. The incorrect URI for the update instructions has undesirable results. You can see this if you simulate the graph in the example by combining the existing note and the activity in a list and entering it into the [Playground](https://json-ld.org/playground/#startTab=tab-canonized&json-ld=%5B%7B%22%40context%22%3A%22https%3A%2F%2Fwww.w3.org%2Fns%2Factivitystreams%22%2C%22id%22%3A%22https%3A%2F%2Fexample.test%2Fnote-1%22%2C%22type%22%3A%22Note%22%2C%22content%22%3A%22Hello%22%2C%22summary%22%3A%22A%20greeting.%22%7D%2C%7B%22%40context%22%3A%22https%3A%2F%2Fwww.w3.org%2Fns%2Factivitystreams%22%2C%22id%22%3A%22https%3A%2F%2Fexample.test%2Fupdate-1%22%2C%22type%22%3A%22Update%22%2C%22object%22%3A%7B%22id%22%3A%22https%3A%2F%2Fexample.test%2Fnote-1%22%2C%22content%22%3A%22Howdy%22%2C%22name%22%3A%22greeting-note%22%2C%22summary%22%3Anull%7D%7D%5D). You’ll see that the Note IRI now has multiple “content” values. You might be able to do some special processing to compensate for that, but it’s not necessary if the “target” property is used.

There are no examples of C2S Update activities in the specification, so using the “target” property for the update target is compliant AFAICT. The S2S Update is a significantly different scenario.

> [@Stricter specifications for pagination of Collections and OrderedCollections](https://socialhub.activitypub.rocks/t/stricter-specifications-for-pagination-of-collections-and-orderedcollections/2633/18):
>
> nonetheless, my take on the Update thing is that it should follow S2S Update semantics.

Are you saying that someone implementing C2S Update behavior should follow the S2S Update semantics? If so, the specification clearly says they are different (partial update versus replacement). There are somewhat different, but similar issues with assigning the “object”'s replacement description with the URI of the replacement target. Your example is fine for one update, but after the second update, both of the previous Update activities will reference the Note state following the second replacement. If someone is looking at the first Update activity it’s not going to be what was originally posted. This is where this topic slightly overlaps with the collection discussion. By using “target” for the replacement target, the historical replacement description (the “object” referent) can remain immutable.

> Update should have its object inlined or embedded in its entirety, so that the “complete replacement” logic can be followed as described in the S2S Update section.

Is that always true? What about something like the following?

```json
  {
    "@context": "https://www.w3.org/ns/activitystreams",
    "id": "https://example.test/update-1",
    "type": "Update",
    "object": "https://example.test/myobject-version-3",
    "target": "https://example.test/myobject"
  }

```

This would tell the server to replace the existing “[https://example.test/myobject](https://example.test/myobject)” with the content of “[https://example.test/myobject-version-3](https://example.test/myobject-version-3)” (maybe the remote server has a special versioning feature). The object _could_ be inlined as a performance optimization, but it could also be dereferenced from the remote server.

---

<div class="post-metadata">

**Author:** ![trwnh](https://socialhub.activitypub.rocks/user_avatar/socialhub.activitypub.rocks/trwnh/32/262_2.png) [@trwnh](https://socialhub.activitypub.rocks/u/trwnh)\
**Post date:** [July 18, 2023, 11:10pm UTC](https://socialhub.activitypub.rocks/t/c2s-s2s-update-issues/3425/2 "2023-07-18T23:10:11Z")

</div>

> [@stevebate](#):
>
> The second resource (the update description) also has an “id” property,

If it’s a C2S Update, it should not have an `id`. C2S activities don;t specify an `id`; the `id` is assigned by the server after the activity has been POSTed to the outbox.

> [@stevebate](#):
>
> Are you saying that someone implementing C2S Update behavior should follow the S2S Update semantics?

No, I’m saying that C2S Update and S2S Update are different; the server should _process_ a C2S Update, but _publish_ an S2S Update. C2S Update follows “partial update” semantics. S2S Update does not.

> [@stevebate](#):
>
> If someone is looking at the first Update activity it’s not going to be what was originally posted. This is where this topic slightly overlaps with the collection discussion. By using “target” for the replacement target, the historical replacement description (the “object” referent) can remain immutable.

This is wrong. `target` is not defined on activities of type `Update`. If you’re dealing with Collections, you use Add / Remove / Move. These activities have a defined `target`.

> [@stevebate](#):
>
> What about something like the following?

> [@stevebate](#):
>
> This would tell the server to replace the existing “[https://example.test/myobject”](https://example.test/myobject%E2%80%9D) with the content of “[https://example.test/myobject-version-3”](https://example.test/myobject-version-3%E2%80%9D) (maybe the remote server has a special versioning feature). The object _could_ be inlined as a performance optimization, but it could also be dereferenced from the remote server.

This is possible with a different activity (someone proposed `as:Replace` once) but I’d hesitate to recommend it. This particular point runs tangent to the other discussion about dereferencing a Create from a different/remote domain: [Who says objects cannot be created elsewhere?](https://socialhub.activitypub.rocks/t/who-says-objects-cannot-be-created-elsewhere/3219)

Other relevant discussions:

- Revision ID? [Revision ID? · Issue #188 · w3c/activitypub · GitHub](https://github.com/w3c/activitypub/issues/188)
- as:Replace proposal: something replaced something else [`as:Replace` proposal: something replaced something else · Issue #538 · w3c/activitystreams · GitHub](https://github.com/w3c/activitystreams/issues/538)

---

<div class="post-metadata">

**Author:** ![stevebate](https://socialhub.activitypub.rocks/user_avatar/socialhub.activitypub.rocks/stevebate/32/2763_2.png) [@stevebate](https://socialhub.activitypub.rocks/u/stevebate)\
**Post date:** [July 19, 2023, 12:36am UTC](https://socialhub.activitypub.rocks/t/c2s-s2s-update-issues/3425/3 "2023-07-19T00:36:58Z")

</div>

> [@trwnh](#):
>
> If it’s a C2S Update, it should not have an `id`. C2S activities don;t specify an `id`; the `id` is assigned by the server after the activity has been POSTed to the outbox.

I agree the C2S client wouldn’t provide an activity URI. There are two “ids” in the example activity. One for the activity (assume it is the server-assigned URI or remove it, it doesn’t change the example) and the “id” of the “object”. The second one is the issue and if it’s not supplied by the client (in _some_ property) how does the server know which object is the update target?

> [@trwnh](#):
>
> This is wrong. `target` is not defined on activities of type `Update`. If you’re dealing with Collections, you use Add / Remove / Move. These activities have a defined `target`.

The AS2 specification defines `Activity` as the domain of the `target` property. My suggestion is consistent with that model. The AP specification _requires_ a `target` for `Add` and `Remove` (`Move` isn’t mentioned in the AP spec), but there’s nothing to prevent using `target` in other activities.

Rereading the AS2 vocabulary spec, it looks like AP changed the semantics of `Update` a bit (and maybe caused some of these issues as a side-effect.)

> [Update] Indicates that the `actor` has updated the `object`. _Note, however, that this vocabulary does not define a mechanism for describing the actual set of modifications made to `object`._

(Emphasis mine.) However, AP _does_ define a mechanism for describing the set of modifications. This seems like a subtle change to the semantics of `object` in the `Update` activity. In AS2, it’s the URI of the object that changed and the server must dereference the URI to get the new state. In AP, the `object` is the set of modifications and the server is expected to apply those changes to an existing target object.

The AS2 description of `Update` goes on to say:

> The `target` and `origin` typically have no defined meaning.

That makes sense if the `Update` is a simple notification that a resource has changed (without specifying _how_ it changed). Given the AP definition of `Update`, I think at least `target` should have a defined meaning.

> [@trwnh](#):
>
> This particular point runs tangent to the other discussion about dereferencing a Create from a different/remote domain: [Who says objects cannot be created elsewhere?](https://socialhub.activitypub.rocks/t/who-says-objects-cannot-be-created-elsewhere/3219)

Yes, that’s why I intentionally made the `object` and `target` be the same domain (and probably the same `actor` or `attributedTo` for authorization purposes).

> [@trwnh](#):
>
> Other relevant discussions:
> 
> - Revision ID? [Revision ID? · Issue #188 · w3c/activitypub · GitHub](https://github.com/w3c/activitypub/issues/188)
> - as:Replace proposal: something replaced something else [`as:Replace` proposal: something replaced something else · Issue #538 · w3c/activitystreams · GitHub](https://github.com/w3c/activitystreams/issues/538)

Thanks for the links. There is some overlap with those topics. I used the word “version” in the last example, but that was a mistake on my part. I’m not talking about versioning or revision histories (other than immutable historical activities, which are only somewhat related). It is interesting that Pieter is also discussing using `target` with `as:Update`, but with slightly different semantics than what I’m suggesting.

---

<div class="post-metadata">

**Author:** ![helge](https://socialhub.activitypub.rocks/user_avatar/socialhub.activitypub.rocks/helge/32/1938_2.png) [@helge](https://socialhub.activitypub.rocks/u/helge)\
**Post date:** [July 20, 2023, 2:41pm UTC](https://socialhub.activitypub.rocks/t/c2s-s2s-update-issues/3425/4 "2023-07-20T14:41:38Z")

</div>

Hi Steve. I do not believe that the ActivityPub specification of the Update activity is sufficient to actually implement it. One can implement “something”, but just looking at what changing recipients entails, one realizes one either needs:

- A complicated algorithm
- Or a quite strict list of stuff being allowed to change [1]

So I think that writing up how Updates can work would be really helpful. In particular, I think that using your target / object pattern will lead to something more understandable than the current spec.

One more remark: I consider sections " 6.2.1 Object creation without a Create Activity" and " 6.3.1 Partial Updates" of the ActivityPub spec, good cases for “Delete and release as ActivityPub 1.1”. They very much feel like a random optimization that does not solve a problem. For example for Updates, I consider it the most trivial best practice to fetch the object before editing, to avoid race conditions. So the client has the full object to edit. Always sending the full object avoids all the awkwardness of deciding if a field was deleted or just not updated.

Thanks.

[1]: If one considers Mastodon, the recipients are determined from the content through mentions, so one cannot change the content.

---

<div class="post-metadata">

**Author:** ![trwnh](https://socialhub.activitypub.rocks/user_avatar/socialhub.activitypub.rocks/trwnh/32/262_2.png) [@trwnh](https://socialhub.activitypub.rocks/u/trwnh)\
**Post date:** [July 20, 2023, 8:09pm UTC](https://socialhub.activitypub.rocks/t/c2s-s2s-update-issues/3425/5 "2023-07-20T20:09:57Z")

</div>

> [@helge](#):
>
> If one considers Mastodon, the recipients are determined from the content through mentions, so one cannot change the content.

You can, though… that’s definitely something you can do.
