Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kiota deletes all but the last plugin in the workspace.json when --refresh is used #6033

Open
garethj-msft opened this issue Jan 16, 2025 · 6 comments
Labels
type:bug A broken experience

Comments

@garethj-msft
Copy link
Member

What are you generating using Kiota, clients or plugins?

Kiota plugin

In what context or format are you using Kiota?

Windows executable

Client library/SDK language

None

Describe the bug

output files are missing after running

kiota plugin generate --refresh with multiple plugins in the workspace.json file.

This does not repro without the --refresh flag

Expected behavior

Expected
six files present after command completes - 3xOpenAPI, 3xplugin manifest

Actual
two files present after command completes - 1xOpenAPI, 1xplugin manifest
These are for the last plugin in the workspace file.

How to reproduce

workspace.json containing three Copilot plugins, with a shared output directory - this is our Copilot project structure

kiota plugin generate --refresh

Open API description file

Not relevant - it's the workspace.json file that is the problem.

Kiota Version

1.22.3

Latest Kiota version known to work for scenario above?(Not required)

No response

Known Workarounds

Specify an individual output directory for each plugin. This makes the project more cluttered.

Configuration

No response

Debug output

Click to expand log ```
</details>


### Other information

Code inspection shows the folder is being wiped in-between each plugin.
@garethj-msft garethj-msft added status:waiting-for-triage An issue that is yet to be reviewed or assigned type:bug A broken experience labels Jan 16, 2025
@github-project-automation github-project-automation bot moved this to Needs Triage 🔍 in Kiota Jan 16, 2025
@andrueastman
Copy link
Member

Thanks for raising this @garethj-msft

Looks like the issue is caused here in the foreach loop where the flag keeps cleaning the output for each plugin to be regerated. Given that all the plugins are in the same folder, only the last one processed will remain.

generationConfiguration.CleanOutput = refresh;

@baywet Any chance you'd be able to confirm if the expectation here was the plugins would be generated in different output folders?

@andrueastman andrueastman removed the status:waiting-for-triage An issue that is yet to be reviewed or assigned label Jan 16, 2025
@andrueastman andrueastman moved this from Needs Triage 🔍 to Ready for development 🧑‍💻 in Kiota Jan 16, 2025
@baywet
Copy link
Member

baywet commented Jan 16, 2025

This behaviour is kind of expected because we've never designed/tested for that (people putting plugins in the same output directory)

I guess the generate command should disable the "CleanOutput" parameter when it detects multiple plugins/clients going to the same output directory.
Or we should re-design the cleanup logic to run once before ALL generations instead of once per generation.

@garethj-msft
Copy link
Member Author

Let me try putting them in separate folders and see if anyone really complains hard.

@andrueastman
Copy link
Member

Thinking about this, since in plugin generation the same files are always generated (openapi file, plugin file, workspace files) which ultimately get overwritten with generation even if --refresh is not passed, setting the "CleanOutput" to true would ultimately mean removing other files in the directory (which would have been placed there by the user since Kiota didn't put them there).

Would it make sense to have the "CleanOutput" to be always false in this scenario?

In my head it only makes sense to use it in client/SDK generation as a modification in the inputs could result in generation of a different set of files (e.g removing/renaming a path has consequences of files needing removing like models/request builders).
Plugin generation will still result in the generation of the same files. Only their contents, will need updating.
Renaming the plugin or changing consequential parameter would ideally happen in a different command like kiota plugin edit

@baywet
Copy link
Member

baywet commented Jan 21, 2025

I think you have a valid point, we could start by disabling it for plugins in the extension, as well ignore it in the CLI.
That first patch would probably clear a lot of the confusion we're seeing across the board and be trivial.

@maisarissi
Copy link
Contributor

@baywet and I had a discussion yesterday and here are some thoughts that came up:

Having a clean output to be performed every time for every client/plugin in the workspace.json doesn't make a lot of sense.
We should create a clean output routine to be used when needed.

For example, why would we do a clean output when generating a client? For regeneration, sure, but why for generation?
Having them decoupled would help us manage better when do the clean up.
The way is set up today, in VS Code (unless I know about the clean output config and go their to change it which many users may don't know) I can't create multiple plugins in the same output, which it's a common scenario (like a DA that you want to expose GitHub API, ADO, and others)

Also, thinking about this scenario where I do have multiple plugins in the same output directory, by having a separate routine, we would do a clean output (remove all files from the output) and then kiota plugin generate, generating all plugins again their. It shouldn't be an issue to issue the --refresh as I do want to make sure a clean up was made before regenerating/generating all plugins there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug A broken experience
Projects
Status: Ready for development 🧑‍💻
Development

No branches or pull requests

4 participants