absmach / magistrala-ui

UI Repository for Magistrala IoT
9 stars 15 forks source link

[BUG] Creating a channel with a parent channel is not possible #44

Closed rodneyosodo closed 5 months ago

rodneyosodo commented 8 months ago

Is there an existing issue for this?

What were you trying to achieve?

Creating a channel with a parent channel when the logged-in user is not a super user

What are the expected results?

To be able to create the channel and view it. The channel has been created but I am not able to view it

What are the received results?

Logs from the UI container

{"level":"warn","message":"Method create_channel took 21.193399ms to complete with error: unexpected end of JSON input : failed to create entity.","ts":"2023-12-18T09:32:16.815958391Z"}
{"level":"info","message":"Method ErrorPage took 3.013488ms to complete without errors.","ts":"2023-12-18T09:32:16.820148485Z"}
{"level":"info","message":"Method list_channels took 19.365223ms to complete without errors.","ts":"2023-12-18T09:32:16.850040967Z"}
{"level":"info","message":"Method get_entities took 3.068194ms to complete without errors.","ts":"2023-12-18T09:32:16.885943613Z"}
{"level":"info","message":"Method list_channels took 21.045913ms to complete without errors.","ts":"2023-12-18T09:32:31.849564301Z"}
{"level":"info","message":"Method get_entities took 3.849686ms to complete without errors.","ts":"2023-12-18T09:32:31.916560383Z"}
{"level":"warn","message":"Method create_channel took 4.537105ms to complete with error: entity already exists : failed to create entity.","ts":"2023-12-18T09:32:39.045759572Z"}
{"level":"warn","message":"Method create_channel took 12.582125ms to complete with error: unexpected end of JSON input : failed to create entity.","ts":"2023-12-18T09:32:45.037177828Z"}
{"level":"info","message":"Method ErrorPage took 5.676889ms to complete without errors.","ts":"2023-12-18T09:32:45.044085156Z"}
{"level":"info","message":"Method list_channels took 21.722683ms to complete without errors.","ts":"2023-12-18T09:32:45.07634593Z"}
{"level":"info","message":"Method get_entities took 3.028468ms to complete without errors.","ts":"2023-12-18T09:32:45.108747336Z"}

Logs from the things container

{"level":"warn","message":"Method create_group for  new_channel  with id  using token eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJkb21haW4iOiIxOTRjZTMzMC0wNDI5LTQ3YWEtOTFiZC0xMDU0YThiM2VlYzgiLCJleHAiOjE3MDI4OTUyNzgsImlhdCI6MTcwMjg5MTY3OCwiaXNzIjoibWFnaXN0cmFsYS5hdXRoIiwic3ViIjoiMTk0Y2UzMzAtMDQyOS00N2FhLTkxYmQtMTA1NGE4YjNlZWM4X2I2NzgxN2FhLWI3ZGItNGY0My04ZDU5LThmNDliNzFjOGE4MyIsInR5cGUiOjAsInVzZXIiOiJiNjc4MTdhYS1iN2RiLTRmNDMtOGQ1OS04ZjQ5YjcxYzhhODMifQ.E_3afzddv2aafFdz4MP4YXc82Fu5XAF5xUY2OIibUPHDbC19pZfg05JZByS487acUDEX6_Ukyx91NMaa0SrJig took 20.492753ms to complete with error: rpc error: code = InvalidArgument desc = failed to add policies : malformed entity specification : unable to satisfy write precondition `operation:OPERATION_MUST_MATCH filter:{resource_type:\"group\" optional_resource_id:\"ad574820-f6d9-48e8-b947-a5af66691f40\" optional_relation:\"domain\" optional_subject_filter:{subject_type:\"domain\" optional_subject_id:\"194ce330-0429-47aa-91bd-1054a8b3eec8\"}}`.","ts":"2023-12-18T09:32:16.815592944Z"}
{"level":"info","message":"Method list_groups 1 groups using token eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJkb21haW4iOiIxOTRjZTMzMC0wNDI5LTQ3YWEtOTFiZC0xMDU0YThiM2VlYzgiLCJleHAiOjE3MDI4OTUyNzgsImlhdCI6MTcwMjg5MTY3OCwiaXNzIjoibWFnaXN0cmFsYS5hdXRoIiwic3ViIjoiMTk0Y2UzMzAtMDQyOS00N2FhLTkxYmQtMTA1NGE4YjNlZWM4X2I2NzgxN2FhLWI3ZGItNGY0My04ZDU5LThmNDliNzFjOGE4MyIsInR5cGUiOjAsInVzZXIiOiJiNjc4MTdhYS1iN2RiLTRmNDMtOGQ1OS04ZjQ5YjcxYzhhODMifQ.E_3afzddv2aafFdz4MP4YXc82Fu5XAF5xUY2OIibUPHDbC19pZfg05JZByS487acUDEX6_Ukyx91NMaa0SrJig took 15.895261ms to complete without errors.","ts":"2023-12-18T09:32:16.846798116Z"}
{"level":"info","message":"Method list_groups 1 groups using token eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJkb21haW4iOiIxOTRjZTMzMC0wNDI5LTQ3YWEtOTFiZC0xMDU0YThiM2VlYzgiLCJleHAiOjE3MDI4OTUyNzgsImlhdCI6MTcwMjg5MTY3OCwiaXNzIjoibWFnaXN0cmFsYS5hdXRoIiwic3ViIjoiMTk0Y2UzMzAtMDQyOS00N2FhLTkxYmQtMTA1NGE4YjNlZWM4X2I2NzgxN2FhLWI3ZGItNGY0My04ZDU5LThmNDliNzFjOGE4MyIsInR5cGUiOjAsInVzZXIiOiJiNjc4MTdhYS1iN2RiLTRmNDMtOGQ1OS04ZjQ5YjcxYzhhODMifQ.E_3afzddv2aafFdz4MP4YXc82Fu5XAF5xUY2OIibUPHDbC19pZfg05JZByS487acUDEX6_Ukyx91NMaa0SrJig took 2.72494ms to complete without errors.","ts":"2023-12-18T09:32:16.885771471Z"}
{"level":"warn","message":"failed to send Mainflux telemetry data with error: unsuccessful sending telemetry data with code 400 and error: <nil>","ts":"2023-12-18T09:32:18.712957299Z"}
{"level":"warn","message":"failed to send Mainflux telemetry data with error: unsuccessful sending telemetry data with code 400 and error: <nil>","ts":"2023-12-18T09:32:29.287097663Z"}
{"level":"info","message":"Method list_groups 1 groups using token eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJkb21haW4iOiIxOTRjZTMzMC0wNDI5LTQ3YWEtOTFiZC0xMDU0YThiM2VlYzgiLCJleHAiOjE3MDI4OTUyNzgsImlhdCI6MTcwMjg5MTY3OCwiaXNzIjoibWFnaXN0cmFsYS5hdXRoIiwic3ViIjoiMTk0Y2UzMzAtMDQyOS00N2FhLTkxYmQtMTA1NGE4YjNlZWM4X2I2NzgxN2FhLWI3ZGItNGY0My04ZDU5LThmNDliNzFjOGE4MyIsInR5cGUiOjAsInVzZXIiOiJiNjc4MTdhYS1iN2RiLTRmNDMtOGQ1OS04ZjQ5YjcxYzhhODMifQ.E_3afzddv2aafFdz4MP4YXc82Fu5XAF5xUY2OIibUPHDbC19pZfg05JZByS487acUDEX6_Ukyx91NMaa0SrJig took 4.293854ms to complete without errors.","ts":"2023-12-18T09:32:31.83299253Z"}
{"level":"info","message":"Method list_groups 1 groups using token eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJkb21haW4iOiIxOTRjZTMzMC0wNDI5LTQ3YWEtOTFiZC0xMDU0YThiM2VlYzgiLCJleHAiOjE3MDI4OTUyNzgsImlhdCI6MTcwMjg5MTY3OCwiaXNzIjoibWFnaXN0cmFsYS5hdXRoIiwic3ViIjoiMTk0Y2UzMzAtMDQyOS00N2FhLTkxYmQtMTA1NGE4YjNlZWM4X2I2NzgxN2FhLWI3ZGItNGY0My04ZDU5LThmNDliNzFjOGE4MyIsInR5cGUiOjAsInVzZXIiOiJiNjc4MTdhYS1iN2RiLTRmNDMtOGQ1OS04ZjQ5YjcxYzhhODMifQ.E_3afzddv2aafFdz4MP4YXc82Fu5XAF5xUY2OIibUPHDbC19pZfg05JZByS487acUDEX6_Ukyx91NMaa0SrJig took 3.41787ms to complete without errors.","ts":"2023-12-18T09:32:31.916342772Z"}
{"level":"warn","message":"Method create_group for  new_channel  with id  using token eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJkb21haW4iOiIxOTRjZTMzMC0wNDI5LTQ3YWEtOTFiZC0xMDU0YThiM2VlYzgiLCJleHAiOjE3MDI4OTUyNzgsImlhdCI6MTcwMjg5MTY3OCwiaXNzIjoibWFnaXN0cmFsYS5hdXRoIiwic3ViIjoiMTk0Y2UzMzAtMDQyOS00N2FhLTkxYmQtMTA1NGE4YjNlZWM4X2I2NzgxN2FhLWI3ZGItNGY0My04ZDU5LThmNDliNzFjOGE4MyIsInR5cGUiOjAsInVzZXIiOiJiNjc4MTdhYS1iN2RiLTRmNDMtOGQ1OS04ZjQ5YjcxYzhhODMifQ.E_3afzddv2aafFdz4MP4YXc82Fu5XAF5xUY2OIibUPHDbC19pZfg05JZByS487acUDEX6_Ukyx91NMaa0SrJig took 4.025736ms to complete with error: entity already exists : ERROR: duplicate key value violates unique constraint \"groups_owner_id_name_key\" (SQLSTATE 23505).","ts":"2023-12-18T09:32:39.045549887Z"}
{"level":"warn","message":"failed to send Mainflux telemetry data with error: unsuccessful sending telemetry data with code 400 and error: <nil>","ts":"2023-12-18T09:32:39.868427462Z"}
{"level":"warn","message":"Method create_group for  new_channel  with id  using token eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJkb21haW4iOiIxOTRjZTMzMC0wNDI5LTQ3YWEtOTFiZC0xMDU0YThiM2VlYzgiLCJleHAiOjE3MDI4OTUyNzgsImlhdCI6MTcwMjg5MTY3OCwiaXNzIjoibWFnaXN0cmFsYS5hdXRoIiwic3ViIjoiMTk0Y2UzMzAtMDQyOS00N2FhLTkxYmQtMTA1NGE4YjNlZWM4X2I2NzgxN2FhLWI3ZGItNGY0My04ZDU5LThmNDliNzFjOGE4MyIsInR5cGUiOjAsInVzZXIiOiJiNjc4MTdhYS1iN2RiLTRmNDMtOGQ1OS04ZjQ5YjcxYzhhODMifQ.E_3afzddv2aafFdz4MP4YXc82Fu5XAF5xUY2OIibUPHDbC19pZfg05JZByS487acUDEX6_Ukyx91NMaa0SrJig took 12.189375ms to complete with error: rpc error: code = InvalidArgument desc = failed to add policies : malformed entity specification : unable to satisfy write precondition `operation:OPERATION_MUST_MATCH filter:{resource_type:\"group\" optional_resource_id:\"733a33c5-c673-4a81-bf7b-7d8194c953d7\" optional_relation:\"domain\" optional_subject_filter:{subject_type:\"domain\" optional_subject_id:\"194ce330-0429-47aa-91bd-1054a8b3eec8\"}}`.","ts":"2023-12-18T09:32:45.036987309Z"}
{"level":"info","message":"Method list_groups 1 groups using token eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJkb21haW4iOiIxOTRjZTMzMC0wNDI5LTQ3YWEtOTFiZC0xMDU0YThiM2VlYzgiLCJleHAiOjE3MDI4OTUyNzgsImlhdCI6MTcwMjg5MTY3OCwiaXNzIjoibWFnaXN0cmFsYS5hdXRoIiwic3ViIjoiMTk0Y2UzMzAtMDQyOS00N2FhLTkxYmQtMTA1NGE4YjNlZWM4X2I2NzgxN2FhLWI3ZGItNGY0My04ZDU5LThmNDliNzFjOGE4MyIsInR5cGUiOjAsInVzZXIiOiJiNjc4MTdhYS1iN2RiLTRmNDMtOGQ1OS04ZjQ5YjcxYzhhODMifQ.E_3afzddv2aafFdz4MP4YXc82Fu5XAF5xUY2OIibUPHDbC19pZfg05JZByS487acUDEX6_Ukyx91NMaa0SrJig took 17.892665ms to complete without errors.","ts":"2023-12-18T09:32:45.072728985Z"}
{"level":"info","message":"Method list_groups 1 groups using token eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJkb21haW4iOiIxOTRjZTMzMC0wNDI5LTQ3YWEtOTFiZC0xMDU0YThiM2VlYzgiLCJleHAiOjE3MDI4OTUyNzgsImlhdCI6MTcwMjg5MTY3OCwiaXNzIjoibWFnaXN0cmFsYS5hdXRoIiwic3ViIjoiMTk0Y2UzMzAtMDQyOS00N2FhLTkxYmQtMTA1NGE4YjNlZWM4X2I2NzgxN2FhLWI3ZGItNGY0My04ZDU5LThmNDliNzFjOGE4MyIsInR5cGUiOjAsInVzZXIiOiJiNjc4MTdhYS1iN2RiLTRmNDMtOGQ1OS04ZjQ5YjcxYzhhODMifQ.E_3afzddv2aafFdz4MP4YXc82Fu5XAF5xUY2OIibUPHDbC19pZfg05JZByS487acUDEX6_Ukyx91NMaa0SrJig took 2.681076ms to complete without errors.","ts":"2023-12-18T09:32:45.108552549Z"}

Steps To Reproduce

  1. Login as normal users
  2. Create Channel 1
  3. Using channel 1 as the parent create channel 2
  4. Try to view channels

In what environment did you encounter the issue?

Git commit - https://github.com/absmach/magistrala-ui/commit/b40e56212d69fea09fb68c32e1006b2ff80de63c Docker Compose version 2.23.3 Docker version

Client: Version: 24.0.7 API version: 1.43 OS/Arch: linux/amd64

Server: Engine: Version: 24.0.7 API version: 1.43 (minimum version 1.12)

Additional information you deem important

For this issue, when I log in as an admin to the same domain where the channels were created, I can see the channels.

image-1

ianmuchyri commented 8 months ago

based on an issue with Magistrala https://github.com/absmach/magistrala/issues/1975