Fix GetReleasePlan to validate TypeSpec path and convert absolute paths to relative before DevOps lookup#15868
Conversation
…path before lookup Co-authored-by: praveenkuttappan <55455725+praveenkuttappan@users.noreply.github.com>
| if (typeSpecHelper.IsValidTypeSpecProjectPath(typeSpecProjectPath)) | ||
| { | ||
| typeSpecProjectPath = typeSpecHelper.GetTypeSpecProjectRelativePath(typeSpecProjectPath); | ||
| } |
There was a problem hiding this comment.
These are duplicate checks. Move this check outside the if to validate the TypeSpec only once and parse the relativeSpec path if TypeSpec path is valid.
There was a problem hiding this comment.
Moved the validation outside the if-else so it runs once upfront, before any lookup branch is taken. Commit: 7c4d5f6 (or see the latest push).
|
@copilot Fix the comment to remove the duplicate check |
… duplication Co-authored-by: praveenkuttappan <55455725+praveenkuttappan@users.noreply.github.com>
Done — the duplicate check is removed. The validation and relative-path conversion now happen once before the if-else block, so both the direct lookup and the PR-fallback branch share the same already-resolved path. |
There was a problem hiding this comment.
Pull request overview
This PR updates ReleasePlanTool.GetReleasePlan to handle absolute local TypeSpec project paths by converting them to the repo-relative specification/... format expected by the Azure DevOps query, and adds a unit test to cover the absolute-path scenario.
Changes:
- Normalize
typeSpecProjectPathinGetReleasePlanby validating it as a local TypeSpec project and converting it to aspecification/...-relative path before performing DevOps lookups. - Add a new unit test covering
GetReleasePlanbehavior when provided an absolute TypeSpec project path.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| tools/azsdk-cli/Azure.Sdk.Tools.Cli/Tools/ReleasePlan/ReleasePlanTool.cs | Adds pre-lookup normalization of valid local TypeSpec paths to specification/... to improve DevOps lookup reliability for absolute paths. |
| tools/azsdk-cli/Azure.Sdk.Tools.Cli.Tests/Tools/ReleasePlan/ReleasePlanToolTests.cs | Adds a test ensuring absolute TypeSpec paths are handled correctly and the DevOps lookup succeeds. |
GetReleasePlanwas passing the TypeSpec project path directly toGetReleasePlanByTypeSpecProjectPathAsync, which expects a repo-relative path (specification/...). Absolute local paths caused the lookup to fail silently.Changes
ReleasePlanTool.cs— Before each call toGetReleasePlanByTypeSpecProjectPathAsync, validate the path withtypeSpecHelper.IsValidTypeSpecProjectPathand convert to relative withtypeSpecHelper.GetTypeSpecProjectRelativePathif valid. Applied to both the direct lookup and the PR-fallback branch.ReleasePlanToolTests.cs— AddedTest_Get_Release_Plan_by_absolute_typespec_project_pathto cover the absolute-path case, verifying it resolves to the correctspecification/...relative path before the DevOps call.Paths that don't resolve locally (already-relative paths with no local tspconfig.yaml) are passed through unchanged, preserving backward compatibility.