anax icon indicating copy to clipboard operation
anax copied to clipboard

'Organization ID contains invalid characters' error after the org is created

Open linggao opened this issue 3 years ago • 3 comments

Got error when creating an org using super user authority. The org is created by failed at other calls with Organization ID contains invalid characters. This error should be reported before creating the org.

hzn exchange org create "ling test" -d "my test org"  --max-nodes 5 -u root/superuser1:superuser1
Organization ling test is successfully added to the Exchange.
Agbot IBM/agbot is responsible for deploying services in org ling test
Error: bad HTTP code 400 from PUT https://cp-console.roks-stg-local-70ea81cdef68a2eb78ece6d890b7dad3-0000.us-south.containers.appdomain.cloud/edge-css/api/v1/organizations/ling test: Organization ID (ling test) contains invalid characters

Debug shows that the error is from MMS.

[verbose] The model management service url: https://cp-console.roks-stg-local-70ea81cdef68a2eb78ece6d890b7dad3-0000.us-south.containers.appdomain.cloud/edge-css
[verbose] PUT https://cp-console.roks-stg-local-70ea81cdef68a2eb78ece6d890b7dad3-0000.us-south.containers.appdomain.cloud/edge-css/api/v1/organizations/ling test
[verbose] HTTP request timeout set to 30 seconds
[verbose] HTTP code: 400
Error: bad HTTP code 400 from PUT https://cp-console.roks-stg-local-70ea81cdef68a2eb78ece6d890b7dad3-0000.us-south.containers.appdomain.cloud/edge-css/api/v1/organizations/ling test: Organization ID (ling test) contains invalid characters

Same problem for org deletion. It seems that the exchange API and the CSS API have different standard for org IDs.

hzn exchange org remove "ling test"  -u root/superuser1:superuser1
Warning: this will also delete all Exchange resources owned by this org (nodes, services, patterns, etc). Are you sure you want to remove org ling test from the Horizon Exchange and the MMS? [y/N]: y
Org ling test is deleted from the Horizon Exchange
Error: bad HTTP code 400 from DELETE https://cp-console.roks-stg-local-70ea81cdef68a2eb78ece6d890b7dad3-0000.us-south.containers.appdomain.cloud/edge-css/api/v1/organizations/ling test

Implementation note: We have documented that "An organization name cannot contain underscores (_), comas (,), blank spaces ( ), single quotes ('), or question marks (?)." In hzn exchange org create we should give error when these character are used for org.

linggao avatar Aug 17 '21 13:08 linggao

same problem exists for ' character and ? character

root@edge-scale-svl-headnode1:~# hzn -v  exchange org create --description="xxx" "agbot'1"
[verbose] Reading configuration file: /etc/horizon/hzn.json
[verbose] Reading configuration file: /etc/default/horizon
[verbose] Config file does not exist: /root/.hzn/hzn.json.
[verbose] No project level configuration file found.
[verbose] The exchange url: https://cp-console.apps.dominion.rtp.raleigh.ibm.com/edge-exchange/v1
[verbose] GET https://cp-console.apps.dominion.rtp.raleigh.ibm.com/edge-exchange/v1/admin/version
[verbose] HTTP request timeout set to 30 seconds
[verbose] HTTP code: 200
[verbose] The exchange url: https://cp-console.apps.dominion.rtp.raleigh.ibm.com/edge-exchange/v1
[verbose] POST https://cp-console.apps.dominion.rtp.raleigh.ibm.com/edge-exchange/v1/orgs/agbot'1
[verbose] HTTP request timeout set to 30 seconds
[verbose] HTTP code: 201
Organization agbot'1 is successfully added to the Exchange.

Agbot IBM/agbot is responsible for deploying services in org agbot'1
[verbose] The model management service url: https://cp-console.apps.dominion.rtp.raleigh.ibm.com/edge-css
[verbose] PUT https://cp-console.apps.dominion.rtp.raleigh.ibm.com/edge-css/api/v1/organizations/agbot'1
[verbose] HTTP request timeout set to 30 seconds
[verbose] HTTP code: 400
Error: bad HTTP code 400 from PUT https://cp-console.apps.dominion.rtp.raleigh.ibm.com/edge-css/api/v1/organizations/agbot'1: Organization ID (agbot'1) contains invalid characters
root@edge-scale-svl-headnode1:~# hzn -v  exchange org create --description="xxx" "agbot?1"



[verbose] HTTP code: 201
Agbot IBM/agbot is responsible for deploying services in org agbot?1

[verbose] PUT https://cp-console.apps.dominion.rtp.raleigh.ibm.com/edge-css/api/v1/organizations/agbot?1
[verbose] HTTP request timeout set to 30 seconds
[verbose] HTTP code: 400
Error: bad HTTP code 400 from PUT https://cp-console.apps.dominion.rtp.raleigh.ibm.com/edge-css/api/v1/organizations/agbot?1: Org ID (agbot) in the URL doesn't match the org-id (agbot?1) in the payload

dlarson04 avatar Sep 07 '21 12:09 dlarson04

Hi , I would like to work on this issue, Please guide me further on, how to get started

himanshu007-creator avatar Sep 21 '21 14:09 himanshu007-creator

@himanshu007-creator in the org creation function https://github.com/open-horizon/anax/blob/master/cli/exchange/org.go#L66, please make sure the input variable theOrg does not contain underscores (_), comas (,), blank spaces ( ), single quotes ('), or question marks (?). Give error and exit out if it does. You can use regex to check.

linggao avatar Sep 21 '21 15:09 linggao

@linggao @johnwalicki Is this issue still pending? If yes, then I would like to work on it. Could you please assign this issue to me?

dipesh-rawat avatar Oct 04 '22 14:10 dipesh-rawat