Skip to content

Share roles returned in a wrong locale #11025

Closed

Description

@LukasHirt

JIRA: #OCISDEV-37

Describe the bug

I changed my locale in the web UI from english to german and then back to english and even though the Accept-Language header is correctly set to en, the permissions endpoint returns share roles in german...

Steps to reproduce

  1. Change locale in web UI into german
  2. Change locale back into english
  3. Go to files list and try to share a file

Expected behavior

Roles are in english

Actual behavior

Roles are in german

Setup

Image

Additional context

This is the request:

curl $'https://host.docker.internal:9200/graph/v1beta1/drives/d757b907-73a5-4847-8e2f-a80dad47e72b%24b1ec0786-e329-404e-9378-38d4a2396f4f/items/d757b907-73a5-4847-8e2f-a80dad47e72b%24b1ec0786-e329-404e-9378-38d4a2396f4f\u00212434ee18-205c-4fcd-be4d-0b08e18786fa/permissions' \
  -H 'accept: application/json, text/plain, */*' \
  -H 'accept-language: en' \
  -H 'authorization: Bearer eyJhbGciOiJQUzI1NiIsImtpZCI6InByaXZhdGUta2V5IiwidHlwIjoiSldUIn0.eyJhdWQiOiJ3ZWIiLCJleHAiOjE3Mzk4NzU2OTAsImlhdCI6MTczOTg3NTM5MCwiaXNzIjoiaHR0cHM6Ly9ob3N0LmRvY2tlci5pbnRlcm5hbDo5MjAwIiwianRpIjoidzQ3Q0NtSFVYNDVKREdBWmVnQ3o1VjF5Zk9yX2MxMnQiLCJsZy5pIjp7ImRuIjoiQWRtaW4iLCJpZCI6Im93bkNsb3VkVVVJRD1iMWVjMDc4Ni1lMzI5LTQwNGUtOTM3OC0zOGQ0YTIzOTZmNGYiLCJ1biI6ImFkbWluIn0sImxnLnAiOiJpZGVudGlmaWVyLWxkYXAiLCJsZy50IjoiMSIsInNjcCI6Im9wZW5pZCBwcm9maWxlIGVtYWlsIiwic3ViIjoiSUlzWUR3Z0tmMHVvVUpqV0BJLTJVR2J5M2ZpWTYtWGlKaFo1bXRrNVNEbWgtNXlleVJjQ21PMTJqUk9Qd203cnBsSE9LcFQtcWdzQUpxUW80VkpuRm5nIn0.COeTKb9mel_SK9eVLDFFn6Z2_w7_sadedsZC7sg8NlhnMdUbgBDETCPMxIPoKK3VK5J_CJHepWKFC10X3XHapycQkzGZJ-u4tf_3IqULqnwB_sTvtzlJOPjOAOPdw1t0tB5es3prlnR2KP19FbNV4iBwxaIVJkE-UjtEmEWFzT7DNxzk_jJYqAbg6_3bLobIdmOMLhPHBCjHjYH5jDXzuQiNl_SfsJFy4Gag9peq0Wqv9ewnC5KVoy1IRzKeqBF-_OSRQIZHSwYeu0DVrMj6cq_GN7UKUGOrtPnrjRhkpuhV8VUD1aKHCgJ3U1GPwtlB9Iwel7iJ8icKwe3a2bEGNrf-uYafA5G9SUSnyvjcwSMsf0RqeWJv1ptXM_90PFcV3owelF75W8GmQ5Cs2ktf3XOtQpMDRpPRXj5u1im7vXNXkX6-FxqtHKAh6QhcXC3WXkYwojkEOhfxqmkxtrbCP0Z-fhA9ghC2ufPd16fn4u1QGedqOiWbTf19r-nETrE-k9ErIXTF56hfH9NVZ-nIfnb3oUDpYaRqpMhlBhYGq0Llqo85_cX-HM8kIkwvjLpU_odU3guFdd1ebNaNVRpdexutG9FZT97usZmMIgDqTXwoePoI1-TOTIrSCydxg-hLj995ofFZmzY6tTivBo7ucZmaDt0oo4Y9RaKpnzlGU-8' \
  -H 'cache-control: no-cache' \
  -H 'initiator-id: 40a2c918-63c3-43f1-95f1-39719292648b' \
  -H 'origin: https://host.docker.internal:9201' \
  -H 'pragma: no-cache' \
  -H 'priority: u=1, i' \
  -H 'referer: https://host.docker.internal:9201/' \
  -H 'sec-ch-ua: "Not(A:Brand";v="99", "Google Chrome";v="133", "Chromium";v="133"' \
  -H 'sec-ch-ua-mobile: ?0' \
  -H 'sec-ch-ua-platform: "macOS"' \
  -H 'sec-fetch-dest: empty' \
  -H 'sec-fetch-mode: cors' \
  -H 'sec-fetch-site: same-site' \
  -H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36' \
  -H 'x-request-id: e316598f-9d32-4827-b960-f674a6de82ef' \
  -H 'x-requested-with: XMLHttpRequest'

Activity

  1. moved this from Qualification to Backlog in Infinite Scale Team Boardon Feb 18, 2025
  2. moved this from Backlog to Qualification in Infinite Scale Team Boardon Feb 18, 2025
  3. LukasHirt commented on Feb 22, 2025

    @LukasHirt
    ContributorAuthor

    The only way I can get the roles translated again in english is to restart the oCIS server.

  4. self-assigned this
    on Mar 12, 2025
  5. 2403905 commented on Mar 12, 2025

    @2403905
    Contributor

    Can't reproduce.

  6. moved this from Qualification to Prio 3 or less in Infinite Scale Team Boardon Mar 17, 2025
  7. dj4oC commented on Apr 16, 2025

    @dj4oC
    Contributor

    I can confirm.

  8. moved this from Prio 3 or less to Backlog in Infinite Scale Team Boardon Apr 16, 2025
  9. LukasHirt commented on Apr 16, 2025

    @LukasHirt
    ContributorAuthor

    I tested this now as well again with latest master and can still reproduce by the steps in the description.

  10. LukasHirt commented on Apr 16, 2025

    @LukasHirt
    ContributorAuthor

    Just noticed that it is not only issue with going back to English. Anytime I switch to any locale, then the share roles are stuck in that locale.

    Reproduction steps:

    1. start oCIS server
    2. login with user with EN locale set
    3. set locale to ES
    4. open sharing dialog and see roles correctly translated into ES
    5. set locale to DE
    6. open sharing dialog and see roles still translated into ES

    My current hunch is that when the translations happen here https://github.com/owncloud/ocis/blob/master/services/graph/pkg/service/v0/api_driveitem_permissions.go#L805 the roles definition maybe gets overwritten from translatable string to the translated string and that's why next time it's not translated?

  11. LukasHirt commented on Apr 16, 2025

    @LukasHirt
    ContributorAuthor

    Yep, seems to be the case with overwriting the source string

    f.SetString(val)

    SetString sets v's underlying value to x.

  12. LukasHirt commented on Apr 16, 2025

    @LukasHirt
    ContributorAuthor

    I just did one extra test to see whether the translatable strings are really being overwritten.

    1. sign in with admin
    2. see roles in EN
    3. change locale to DE
    4. see roles in DE
    5. sign out
    6. sign in with einstein
    7. even though einstein has locale set to EN, see roles in DE
    Zaznam.obrazovky.2025-04-16.v.22.48.14.mov

    This seems to confirm my hunch and also shows that the issue is a bit bigger as a single user changing his locale affects all other users...

  13. moved this from Backlog to In progress in Infinite Scale Team Boardon Apr 16, 2025
  14. 2403905 commented on Apr 16, 2025

    @2403905
    Contributor

    @LukasHirt I updated the pr.
    Ocis used the global slice buildInRoles of roles and tried to clone the slice each time. But theslices.Clone function doesn't work properly, that why the transaction overwrites roles globally.

    buildInRoles = []*libregraph.UnifiedRoleDefinition{

    slices.Clone(roles),

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions