Skip to content

Ensure ETag is quoted per spec and clean up redundant COA metadata headers - #72

Merged
vireshnavalli merged 3 commits into
developmentfrom
fix/385-etag-header
Sep 15, 2026
Merged

vireshnavalli merged 3 commits into
developmentfrom
fix/385-etag-header

Conversation

@sanjujunnuthula

@sanjujunnuthula sanjujunnuthula commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

This PR resolves an issue with the ETag HTTP response header formatting on the bundle and deployment download endpoints (/clients/{clientId}/bundles/{digest} and /clients/{clientId}/deployments/{deploymentId}/{digest}) to comply with the Margo API specification

It also cleans up duplicate header serializations in Coa_meta_header.

  1. Quoted ETag: Enclosed the digest in double quotes (e.g., "sha256:<digest>") in device-agent-vendor.go and helpers.go to match the API specification ("Quoted digest of the returned bundle archive").
  2. Removed Redundant Coa_meta_header: Cleaned up the metadata mapping in createSuccessResponseWithHeaders so that standard HTTP headers are not duplicated as a JSON blob inside Coa_meta_header.
image

…aders

Signed-off-by: sanjujunnuthula <sanjuvardhan.junnuthula@capgemini.com>
@sanjujunnuthula sanjujunnuthula changed the title ensure ETag is quoted per spec and clean up redundant COA metadata headers Ensure ETag is quoted per spec and clean up redundant COA metadata headers Sep 10, 2026
@sanjujunnuthula sanjujunnuthula self-assigned this Sep 10, 2026
@sanjujunnuthula sanjujunnuthula added the bug Something isn't working label Sep 10, 2026
deviceVendorLogger.InfofCtx(pCtx, "Set response headers directly - ETag: %s", actualDigest)
} else {
deviceVendorLogger.WarnfCtx(pCtx, "Could not access fasthttp context to set headers")
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

seems this block got duplicated, can we have single function which get called for both API routes?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

ok


builder := NewResponseBuilder(span).
WithContentType(contentType).
WithMetadata(metadata).

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The createSuccessResponseWithHeaders function is shared/common in helpers.go, but the PR modifies it to always clear metadata. Is this intentional? Any impact to other endpoints?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, this is intentional, as createSuccessResponseWithHeaders helper is been only used only bundle and deployment download functions, it doesnt impact other end points

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@sanjujunnuthula If that is the case why can't you send nil instead of headers, highlighted block should be nil, which you are setting explicitly outside function call,

map[string]string{
"Content-Type": "application/yaml",
"Cache-Control": "public, max-age=31536000, immutable",
"ETag": fmt.Sprintf(""%s"", actualDigest), // Quoted ETag
"Vary": "Accept-Encoding",
},

return createSuccessResponseWithHeaders(span,
	"application/yaml",
	nil,
	v1alpha2.OK,
	&yamlContent,
)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

ok

@@ -900,6 +913,18 @@ func (self *DeviceAgentVendor) downloadDeployment(request v1alpha2.COARequest) v
"Serving deployment %s with verified digest %s (%d bytes)",
deploymentId, actualDigest, len(yamlContent))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Don't modify createSuccessResponseWithHeaders at all. Just set headers directly on fasthttp and don't pass metadata:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

ok

Signed-off-by: sanjujunnuthula <sanjuvardhan.junnuthula@capgemini.com>
Signed-off-by: sanjujunnuthula <sanjuvardhan.junnuthula@capgemini.com>

@spulkit138 spulkit138 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks Good! Can be merged if tested.

@vireshnavalli
vireshnavalli merged commit 2b91f55 into development Sep 15, 2026
@vireshnavalli
vireshnavalli deleted the fix/385-etag-header branch September 15, 2026 08:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants