DependencyTrack / DependencyTrack/dependency-track

PATCH v1/project with only "active" property sets isLatest to "false"

Open
#5,279 4 comments 3 reactions 0 assignees View on GitHub
defect p2 size/S
Dominant language
Java
Stars
4.2k
Forks
811
Avg merge
8h 39m
Merged PRs (30d)
237

Description

### Current Behavior

I'm sending a PATCH /v1/project/{uuid} request to set the "active" flag to "false". Afterwards, the project's "isLatest" flag is also "false".

This is the request I'm sending:

```csharp
string requestUri = $"v1/project/{projectId:D}";

var request = new Project
{
Active = false // or true
};

var responseMessage = await client
.PatchAsJsonAsync(requestUri, request, JsonSerializerOptions.Web, cancellationToken)
.ConfigureAwait(false);
```

This is the definition of the `Project` type (it's minimal since I don't use a lot of fields at the moment):

```csharp
class Project
{
public string Uuid { get; set; } = default!;
public string? Name { get; set; }
public string? Version { get; set; }
public bool? IsLatest { get; set; }
public bool? Active { get; set; }
public ProjectClassifier? Classifier { get; set; }
public ExternalReference[]? ExternalReferences { get; set; }
}
```

As you can see, all properties are nullable, and therefore all of them will be `null`. Even the "required" attribute `Uuid` will be `null` (since that it is the `default` value for the `string` type).

I have verified the object has no other properties set than `Active`.

### Steps to Reproduce

1. Create a project that's active and latest.
2. Use PATCH /v1/project/{uuid} with JSON to set active to false or true.

### Expected Behavior

Active is false/true, but IsLatest remains unchanged.

(Information on the environment data below: I'm just a programmer who was tasked to program automations using the API, so I don't know the database server.

### Dependency-Track Version

4.13.4

### Dependency-Track Distribution

Container Image

### Database Server

N/A

### Database Server Version

_No response_

### Browser

N/A

### Checklist

- [x] I have read and understand the [contributing guidelines](https://github.com/DependencyTrack/dependency-track/blob/master/CONTRIBUTING.md#filing-issues)
- [x] I have checked the [existing issues](https://github.com/DependencyTrack/dependency-track/issues) for whether this defect was already reported

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.