Test Permissions - The resource 'XXX' was not found

Hi

Self hosted Octopus version 2021.3 (Build 8272)

When using the Test Permissions for some users (but not all) I receive an error:

The resource 'XXX' was not found

The error seems to come from an underlying a call to:

/api/Spaces-1/projects/all

which returns the same error message.

Any advice on how to resolve this?

Regards
Ceri

Hi @ceri.lewis,

Thanks for reaching out to Octopus Support, and welcome to our forums!
Sorry to hear you’re experiencing a resource not found error.

When that error comes back on the project’s endpoint, it usually means there’s a data-link issue between something inside a project and the deployment settings or channel configurations attached.

Do you have many projects in Spaces-1? Would it be possible for you to iterate through them manually and see which one, in particular, is causing the error?
You can do this simply by opening the project; the project itself should be inaccessible due to that error.

We can suggest a couple of fixes once we know more about what is causing the data issue; the most common cause is that a step used for release versioning has been modified. The deployment settings for the project can no longer find that step; hence: “The resource ‘xxx’ was not found.”
Often, the resource that can’t be found can be a clue as to what the issue is and where the issue lies.

Let me know if you’re able to track down the culprit project.
It would be ideal if you’re able to get the Projects-ID of the project but don’t worry if you’re not able to; a lot of the API calls that would retrieve such information also query the project directly, so may throw this error also.

If you have any further questions or concerns, feel free to ask away, and I’ll do my best to answer.

Kind Regards,
Adam

Hi.
Thanks for your response.

There are more than 400 projects in that space so I iterated over them using the Rest API. I have found the offending project (and Project-ID). It is currently marked as Disabled when viewed in the UI. What should I now?

Thanks
Ceri

Hi @ceri.lewis,

Thanks for getting back to us!

Does it appear that the resource that can’t be found is a process step that has been modified or deleted?

If this is the case, I can send over a script that will reset the versioning strategy of the project, which will then allow you access to the project to set the settings accordingly.

The script creates a temporary project, takes the fresh deployment settings, modifies them to match the broken project and then uses an API PUT request to place the settings within the broken project. The temporary project is then deleted.

The variables you’ll be required to modify are:
$octopusUrl
$octopusAPIKey
$projectGroupName - Any project group name that exists within Spaces-1 will do, as the project is deleted afterwards.
$lifecycleName - The name of the default lifecycle within Spaces-1.

# Create Script Variables
$octopusUrl = "https://OctopusURL"
$octopusAPIKey = "API-XXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
$header = @{ "X-Octopus-ApiKey" = $octopusAPIKey }

# Case Specific Variables | Customise Lifecycle Name and Project Group if necessary.
$spaceId = "Spaces-1"
$newProjectName = "Project_For_Template"
$newProjectDescription = "Project created for version template to fix broken references. Will be deleted after."
$projectGroupName = "Default Project Group"
$lifecycleName = "Default lifecycle"

# BROKEN PROJECT ID
$brokenProjectId = "Projects-XX"

# Get Project Group Id
$projectGroup = (Invoke-RestMethod -Method Get "$octopusURL/api/$($spaceId)/projectgroups/all" -Headers $header) | Where-Object {$_.Name -eq $projectGroupName}

# Get Lifecycle Id
$lifeCycle = (Invoke-RestMethod -Method Get "$octopusURL/api/$($spaceId)/lifecycles/all" -Headers $header) | Where-Object {$_.Name -eq $lifecycleName}

# JSON Payload for template project
$jsonPayload = @{
    Name = $newProjectName
    ProjectGroupId = $projectGroup.Id
    LifeCycleId = $lifeCycle.Id
}

# Create new project
$newProject = Invoke-RestMethod -Method Post -Uri "$octopusURL/api/$($spaceId)/projects" -Body ($jsonPayload | ConvertTo-Json -Depth 10) -Headers $header

# Gather deployment settings template
$depTemplate = Invoke-RestMethod -Method Get -Uri "$octopusURL$($newProject.Links.DeploymentSettings)" -Headers $header

# Copy and modify template to match broken project
$newDepSettings = $depTemplate
$newDepSettings.Id = $newDepSettings.Id.replace($newProject.Id, $brokenProjectId)
$newDepSettings.ProjectId = $newDepSettings.ProjectId.replace($newProject.Id, $brokenProjectId)

# Determine deployment settings URL for broken project
$newUrl = $newProject.Links.DeploymentSettings.replace($newProject.Id, $brokenProjectId)

# Upload newly created default deployment settings to broken project
Invoke-RestMethod -Method Put -Uri "$octopusURL$($newUrl)" -Headers $header -Body ($newDepSettings | ConvertTo-Json -Depth 10)

# Delete Template Project
Invoke-RestMethod -Method Delete -Uri "$octopusURL/api/$($spaceId)/projects/$($newProject.Id)" -Headers $header

I hope this helps! Let me know if you’re able to access the project after running this script.

Kind Regards,
Adam

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.