I have…
- Checked the logs and have uploaded a log file and provided a link because I found something suspicious there. Please do not post the log file in the topic because very often something important is missing.
I’m submitting a…
- Regression (a behavior that stopped working in a new release)
- Bug report
- Performance issue
- Documentation issue or request
Current behavior
I have created an app on Squidex (via Internet browser) called “mycms”.
After that I perform the following steps on Squidex CLI:
- Add an app with
sq config app mycms mycms:default xxxxxx
where xxxxxx is the client secret;
- Execute
sq apps list
and get an empty JSON array: []
;
- Execute
sq apps create --app "chunlin-test"
and get an output “App creation completed.” returned;
- Execute
sq apps list
and receive the following JSON:[
{
"id": "23fc4c3d-0c0b-4578-a026-94716151a66b",
"name": "chunlin-test",
"version": 2,
...
}
]
- Execute
sq apps delete --app chunlin-test --confirm chunlin-test
and get the message “App deletion completed.”;
- Both the apps “mycms” and “chunlin-test” are deleted.
Expected behavior
- The
sq apps list
should show “mycms” too instead of just “chunlin-test”;
- The
sq apps delete --app chunlin-test --confirm chunlin-test
should delete only “chunlin-test” but not “mycms”.
Minimal reproduction of the problem
As listed in the section “Current behavior”.
Environment
- Self hosted with docker
- Self hosted with IIS
- Self hosted with other version
- Cloud version
- Squidex CLI
Version: [VERSION]
Browser:
- Chrome (desktop)
- Chrome (Android)
- Chrome (iOS)
- Firefox
- Safari (desktop)
- Safari (iOS)
- IE
- Edge
Others:
Weird, I don’t see the bug at the moment. If you have idea, a PR would be welcome.
Noted, @Sebastian.
I have some questions before I create the PR just so that I understand the issue correctly.
Is starting to use the Squidex CLI with sq config app ...
the right way?
If yes, for the command sq apps list
, is it supposed to include the app that we indicate in sq config app ...
?
Apps list gives you all the apps in the installation. I think there is also config view
or config list
Thank you for your explanation, @Sebastian.
I think I roughly know why the deletion may have issue.
At the method Delete, we have the following line.
var name = arguments.App;
So when we run the command sq apps delete --app chunlin-test --confirm chunlin-test
, the name
will be “chunlin-test”. At the same time, arguments.Confirm
will also be “chunlin-test”. Hence, the following if statement will be false.
if (!string.Equals(name, arguments.Confirm, StringComparison.Ordinal))
This means that it will proceed to execute the following line.
await session.Client.Apps.DeleteAppAsync();
This line will delete the app with the app name from _options.AppName
instead because neither arguments.App
nor arguments.Confirm
is being passed to the DeleteAppAsync
.
What is your opinion on this? Would you mind sharing your thoughts on how we should approach this issue?
Thank you for your time attending to this!
The client where - the CLI is based on - takes the app name from the options.
The --name
argument is generic and actually decides which app from the configuration to choose. This is what StartSession(options.App)
does. So I think this cannot be the reason.
Yes, the --name
is generic but it does not really decide which app from the configuration to choose to delete.
Let me share with you with steps to illustrate further.
Step 1: I have an app called “mycloud” on Squidex, as shown in the following screenshot.
Step 2: I run the command: sq config list --table
. It returns me the following output.
----------------------------------------------------------------------------------------------
| Name | App | ClientId | ClientSecret | Url |
----------------------------------------------------------------------------------------------
| mycloud | mycloud | mycloud:default | tkk4i5z... | https://squidexcms.gcl-team.com |
----------------------------------------------------------------------------------------------
Count: 1
Current App: mycloud
Step 3: I run the command: sq apps list
. It returns me an empty array:
[]
Step 4: I run the command sq apps delete --app chunlin-test --confirm chunlin-test
, it shows the following.
> App deletion completed.
Step 5: Now I visit again the Squidex page, the app “mycloud” is already deleted, as shown in the screenshot attached at my next reply below.
As we can see, even though we have specified to delete the app “chunlin-test” with the --name
, which is an app not even exists, the CLI proceeds and deletes the “mycloud” app which is not even indicated in the deletion command.
Hence, this leads me to think whether merely checking the equality of name
and confirm
is enough.
Hope this clear your doubts and thank you again for your time!
Attach the Step 5 screenshot here:
I think there are some misconceptions:
--name
will use the config with the name, if it exists, otherwise the selected one.
sq apps list
will return all apps where the user is a contributor. This basically only works if the client is created for a user in the profile page.
- The confirm does not compare if the name is the same as the selected app, but uses the
--name
flag instead. I think this is the bug: squidex-samples/cli/Squidex.CLI/Squidex.CLI/Commands/App_Apps.cs at e5fa5a279316e97ff22dbca388a86efa50f7e8e3 · goh-chunlin/squidex-samples · GitHub. So Line 76 to 81 can be removed and then the comparison should be done with the session.App variable in line 83
Noted with thanks.
Is it fine if I create a PR to fix your 3rd point in the sq apps delete
, i.e. removing the Lines 76 to 81 and do the comparison with session.App
?
Of course, looking forward
…
Thank you! I have created the PR. =)
TYVM. I created a new release with your changes
1 Like