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

Blocked non-list operations on adapters #525

Merged
merged 13 commits into from
Aug 30, 2024

Conversation

anmenaga
Copy link
Contributor

PR Summary

Fix #516

Currently when non-list operations are executed on an adapter the error message is misleading;
This PR adds a check early in the call chain and prints a clear error message.

For example:

PS C:\DSCv3> dsc.exe resource export -r "Microsoft.DSC/PowerShell"   
2024-08-21T21:04:41.326009Z ERROR Can not perform this operation on the adapter Microsoft.DSC/PowerShell itself

@anmenaga anmenaga force-pushed the issue_516 branch 2 times, most recently from 17f211c to 72bb968 Compare August 21, 2024 21:29
Copy link
Member

@SteveL-MSFT SteveL-MSFT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like the check should be in the lib instead of the exe, perhaps here? https://github.com/PowerShell/DSC/blob/main/dsc_lib/src/dscresources/dscresource.rs#L190

@anmenaga
Copy link
Contributor Author

anmenaga commented Aug 30, 2024

Seems like the check should be in the lib instead of the exe, perhaps here? https://github.com/PowerShell/DSC/blob/main/dsc_lib/src/dscresources/dscresource.rs#L190

I've tried this, but realized that because the way we call adapted resources (we substitute adapted resource with adapter before calling lib's get/set/etc...) a way to differentiate between a call on an adapted resource vs call on an adapter within the lib is not trivial and I think it's not worth it.

@SteveL-MSFT SteveL-MSFT added this pull request to the merge queue Aug 30, 2024
Merged via the queue into PowerShell:main with commit f42d1fb Aug 30, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Better error message when no input is provided to PowerShell adapters
2 participants