The Error Response messages from neutron_lib/exceptions.py are not getting translated due to missing translation files

Bug #1616357 reported by Esha Seth
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
neutron
Invalid
Undecided
Unassigned

Bug Description

When a GET or a POST REST API request is made to openstack neutron for openstack/networks/v2.0/networks with invalid data then the response message with 404 error code is not translated

Response:
 {
    "NeutronError":
    {
        "message": "Network dcea3730-ddc6-48cf-a1e9-26cea79074d9 could not be found.",
        "type": "NetworkNotFound",
        "detail": ""
    }
}

Revision history for this message
Reedip (reedip-banerjee-deactivatedaccount) wrote :

If possible, can you explain a bit more in what you expect as the output?
Arent we getting "Network not Found" if the network doesnt exist ( i.e. for Invalid data )

Revision history for this message
Esha Seth (eshaseth) wrote :

The issue is with the result not getting translated when other locale is enabled.It always returns English.

For eg: In cinder following is returned after translation for incorrect data:
GET for openstack/volume/v2/cafabe5dfa87448d950914a3983d05e1/volumes/793c1e3a-8f32-4291-8089-0af3bc1dee4
Response is translated as following:

Response:

    {
        "itemNotFound":
        {
            "message": "[G'Volume 793c1e3a-8f32-4291-8089-0af3bc1dee4 could not be found.ฏูİı|]",
            "code": 404
        }
    }

Revision history for this message
Armando Migliaccio (armando-migliaccio) wrote :

How are you performing the request?

tags: added: api low-hanging-fruit
Changed in neutron:
status: New → Incomplete
Revision history for this message
Armando Migliaccio (armando-migliaccio) wrote :

Can you provide more details, such as the release?

Revision history for this message
Esha Seth (eshaseth) wrote :

The release is Newton in which this is observed

Revision history for this message
Esha Seth (eshaseth) wrote :

GET:https://<ip>/openstack/network/v2.0/networks/dcea3730-ddc6-48cf-a1e9-26cea79074d9

tamil vanan (tamilhce)
Changed in neutron:
assignee: nobody → tamil vanan (tamilhce)
Esha Seth (eshaseth)
Changed in neutron:
status: Incomplete → In Progress
tamil vanan (tamilhce)
Changed in neutron:
assignee: tamil vanan (tamilhce) → nobody
Revision history for this message
Esha Seth (eshaseth) wrote :

There are 2 issues here related to GET/POST networks api

The POST call for which defect was raised is returning the webob/exc.py HTTPNotFound(HTTPClientError) which is a 404 and is not translated.(https://github.com/Pylons/webob/blob/master/webob/exc.py line 702

Example:
When tried to modify a non existing network id the resource not found message received is not translated when another language is enabled (always returns english)

Post :https://<serverip>/openstack/network/v2.0//networks/dcea3730-ddc6-48cf-a1e9-26cea79074d0

Body:
{"network":{"name":"Vlan456","provider:network_type":"vlan","provider:physical_network":"default","provider:segmentation_id":457}}

Response (using RestClient) :

<html>
<head>
<title>404 Not Found</title>
</head>
<body>
<h1>404 Not Found</h1>
The resource could not be found.<br /><br />
</body>
</html>

The GET call for invalid data is returning a NeutronError of NetworkNotFound but the message here is not translated. I think this is related to convert_exception_to_http_exc in https://github.com/openstack/neutron/blob/master/neutron/api/api_common.py

Though according to https://github.com/openstack/neutron-lib/blob/master/neutron_lib/exceptions.py NetworkNotFound at line 115 should be translated.

Example:
Invalid ID:
GET:https://<ip>/openstack/network/v2.0/networks/dcea3730-ddc6-48cf-a1e9-26cea79074d9

Response:
 {
    "NeutronError":
    {
        "message": "Network dcea3730-ddc6-48cf-a1e9-26cea79074d9 could not be found.",
        "type": "NetworkNotFound",
        "detail": ""
    }
}

"Network dcea3730-ddc6-48cf-a1e9-26cea79074d9 could not be found." message should get translated to other language and not always return english.

We need both these to translated.

Changed in neutron:
status: In Progress → New
Revision history for this message
Esha Seth (eshaseth) wrote :

For GET call:
If the messsage NetworkNotFound is actually coming from https://github.com/openstack/neutron-lib/blob/master/neutron_lib/exceptions.py , the translation for this library/project is not in place. ie the messages are written correctly like _() but I don't see any local directory or .op files under the locale directory .

The setup.cfg file has all the sections filled out >> https://github.com/openstack/neutron-lib/blob/master/setup.cfg#L35-#L47 .. for this reason, I don't think none of the message that come from neutron_lib is translated.

The POST call for which defect was raised is returning the webob/exc.py HTTPNotFound(HTTPClientError) which is a 404 and is not translated.(https://github.com/Pylons/webob/blob/master/webob/exc.py line 702 . This should be translated by using _() and corresponding translation files (mo, .op)

Esha Seth (eshaseth)
summary: - The Error Response REST API GET/POST on networks is not translated
+ The Error Response messages from neutron_lib/exceptions.py are not
+ getting translated due to missing translation files
Boden R (boden)
tags: added: lib
Revision history for this message
Esha Seth (eshaseth) wrote :

I digged more and found that no translation files exist for neutron_lib.

Another example:

the explanation message while giving invalid gateway is partially hard-coded. (See Invalid input for Operation)

[G'Unable to add network [أبتث_Network].ฏูİı|]

POST 'https://<ip>/openstack/network/v2.0//subnets'

Source:
{"subnet":{"network_id":"274f5e1f-9326-4b57-a1fc-3e835e507cb9","cidr":"15.15.15.0/24","enable_dhcp":false,"ip_version":"4","gateway_ip":"15.15.15.0","dns_nameservers":[],"allocation_pools":[{"start":"15.15.15.1","end":"15.15.15.254"}]}}

Response:
{"NeutronError": {"message": "Invalid input for operation: [G'\uff27\uff41\uff54\uff45\uff57\uff41\uff59 \uff49\uff53 not valid on subnet\u0e0f\u0e39\u0130\u0131\uff5c].", "type": "InvalidInput", "detail": ""}}

Revision history for this message
Akihiro Motoki (amotoki) wrote :

Translation setup for neutron-lib is configured appropriately [1].
Zanata (OpenStack translation platform) has neutron-lib resource as expected [2] but there is no language translates messages over 75%.
Translation import job in OpenStack infra imports translations only for languages with 75% translation [3].
As a result, no translation files exist for neutron-lib.

This is an expected result.

[1] http://git.openstack.org/cgit/openstack-infra/project-config/tree/zuul/layout.yaml#n11724
[2] https://translate.openstack.org/iteration/view/neutron-lib/master/documents/neutron_lib%2Flocale%2Fneutron_lib
[3] http://git.openstack.org/cgit/openstack-infra/project-config/tree/jenkins/scripts/common_translation_update.sh#n554

Revision history for this message
Akihiro Motoki (amotoki) wrote :

This is an expected behavior, so I mark this as Invalid.

If you want to have the current translation for your language,
download translation for your language from https://translate.openstack.org/iteration/view/neutron-lib/master/languages

Changed in neutron:
status: New → Invalid
tags: added: i18n
Changed in neutron:
importance: Undecided → Low
importance: Low → Undecided
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.