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

fix(deployments): align omitempty usage #357

Merged
merged 1 commit into from
Jan 15, 2025
Merged

Conversation

mitchnielsen
Copy link
Contributor

Aligns the omitempty usage with the expectations from the API.

Required fields should not set omitempty.
Optional fields should set omitempty, when we don't want to send empty values.

We don't need omitempty on the object struct, just for structs used in API calls that get (un)marshalled.

Closes https://linear.app/prefect/issue/PLA-919/manifest-path-causes-deployment-update-to-fail-prefect-server

Closes #356

Aligns the omitempty usage with the expectations from the API.

Required fields should not set omitempty.
Optional fields should set omitempty, when we don't want to send
empty values.

We don't need omitempty on the object struct, just for structs used in
API calls that get (un)marshalled.

Closes https://linear.app/prefect/issue/PLA-919/manifest-path-causes-deployment-update-to-fail-prefect-server

Closes #356
@@ -74,7 +74,7 @@ type DeploymentUpdate struct {
EnforceParameterSchema bool `json:"enforce_parameter_schema,omitempty"`
Entrypoint string `json:"entrypoint,omitempty"`
JobVariables map[string]interface{} `json:"job_variables,omitempty"`
ManifestPath string `json:"manifest_path"`
ManifestPath string `json:"manifest_path,omitempty"`
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the fix for #356 specifically.

@@ -50,10 +50,10 @@ type DeploymentCreate struct {
Description string `json:"description,omitempty"`
EnforceParameterSchema bool `json:"enforce_parameter_schema,omitempty"`
Entrypoint string `json:"entrypoint,omitempty"`
FlowID uuid.UUID `json:"flow_id"`
FlowID uuid.UUID `json:"flow_id"` // required
Copy link
Contributor Author

Choose a reason for hiding this comment

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

There's no required option (that I'm aware of), so I added // required here to signify that we're intentionally not specifying omitempty. My thought process was this may help us in the future to determine whether the field was left off intentionally or not - open to opinions though

@@ -22,25 +22,25 @@ type Deployment struct {
WorkspaceID uuid.UUID `json:"workspace_id"`

ConcurrencyLimit *int64 `json:"concurrency_limit"`
ConcurrencyOptions *ConcurrencyOptions `json:"concurrency_options,omitempty"`
Description string `json:"description,omitempty"`
ConcurrencyOptions *ConcurrencyOptions `json:"concurrency_options"`
Copy link
Contributor Author

Choose a reason for hiding this comment

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

AFAIK, there's no need to specify omitempty on the Deployment object itself because it's not used in any API requests and is therefore never (un)marshalled by the json package.

@mitchnielsen mitchnielsen marked this pull request as ready for review January 15, 2025 17:37
@mitchnielsen mitchnielsen requested a review from a team as a code owner January 15, 2025 17:37
@mitchnielsen mitchnielsen merged commit 3ac1fa6 into main Jan 15, 2025
7 checks passed
@mitchnielsen mitchnielsen deleted the fix-manifest-path branch January 15, 2025 20:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix Fixing a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

manifest_path causes deployment update to fail (Prefect Server)
3 participants