Skip to content

fix(UI): share links not storable#198

Open
utnapischtim wants to merge 1 commit intoinveniosoftware:masterfrom
utnapischtim:fix-shared-links-with-anonymous
Open

fix(UI): share links not storable#198
utnapischtim wants to merge 1 commit intoinveniosoftware:masterfrom
utnapischtim:fix-shared-links-with-anonymous

Conversation

@utnapischtim
Copy link
Contributor

@utnapischtim utnapischtim commented Mar 10, 2026

  • the problem is that the anonymous users are not handled for shared
    links in the audit logs

  • this creates the situation that 'None' is given to int() which expects
    to convert a stringified number and fails

  • this fix is not ideal since it assumes that if the user_id is of type
    str and has the value 'None' it should be an anonymous user

closed: inveniosoftware/invenio-app-rdm#3338

@utnapischtim utnapischtim force-pushed the fix-shared-links-with-anonymous branch from 99cbc61 to ee7bb64 Compare March 10, 2026 12:33
Comment on lines +39 to +40
elif user_id == "None": # why str?
return self.anonymous_user({"id": user_id})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we expose "None" as the user id in the serialized output?
Would using a clearer sentinel like "anonymous" be better searchable in logs then None?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, that is a good question. i thought that too, but since the user_id should be an int anonymous would be wrong and yes None is also wrong, but at least more in the way of a None type

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is "None" because here it gets typecast into string. I guess the resolver here should handle both? None and "None" or maybe instead "" and empty string should be passed from the audit log builder?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

which values can user_id have? or better which values can identity.id have?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I can find in the codebase, it could only be the user ids, 'system' and now we will have 'None' for anonymous user.

username = fields.Constant(_("Deleted user"), dump_only=True)


class AnonymousSchema(Schema):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this schema inherit from BaseGhostSchema like UserGhostSchema to keep the serialized structure consistent across special user types?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BaseGhostSchema has a is_ghost attribute which in my thinking doesn't apply to an AnonymousUser. For me it should not inherit from BaseGhostSchema

dump_only=True,
)
username = fields.Constant(_("Anonymous user"), dump_only=True)
email = fields.Constant("anonymous_user@anonymous.ch", dump_only=True)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following the same approach as SystemUserSchema. I would propose

Suggested change
email = fields.Constant("anonymous_user@anonymous.ch", dump_only=True)
email = fields.Constant("anonymous@inveniosoftware.org", dump_only=True)

* if the user_id is of type str and has the value 'None' it fails with
  ValueError on converting to int with int()

* this happens when an anonymous user tries to save a draft over a
  shared link

* this fix is not ideal since it assumes that if the user_id is of type
  str and has the value 'None' it should be an anonymous user
@utnapischtim utnapischtim force-pushed the fix-shared-links-with-anonymous branch from ee7bb64 to 0cb9e4a Compare March 15, 2026 21:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Share edit link can not be saved and similar for external user.

3 participants