Skip to content

Gateway: Possible Invalid 'X-Ipfs-Roots' Header #221

@hacdias

Description

@hacdias

Extracted from #176 (comment) to avoid blocking #176.

⚠️ since pathMetadata is based on maybeResolvedImPath, if the path is indeed resolved to the final /ipfs/cid, we will produce an invalid X-Ipfs-Roots header that does not include logical parents from immutableContentPath.

Example:

  • immutableContentPath/ipfs/cid/foo/bar
  • maybeResolvedImPath/ipfs/bar-cid
  • X-Ipfs-Roots
    • expected: cid, foo-cid, bar-cid
    • produced: bar-cid

Idea

Maybe some struct that gets passed around, like:

type requestData struct {
	// Defined for all requests.
	begin             time.Time
	logger            *zap.SugaredLogger
	contentPath       ipath.Path
	contentType       string
	contentTypeParams map[string]string

	// Defined for non IPNS Record requests.
	immutablePath ImmutablePath

	// Defined if resolution has already happened.
	pathMetadata *ContentPathMetadata
	resolvedPath *ImmutablePath
}

func (rq *requestData) maybeResolvedPath() ImmutablePath {
	if rq.resolvedPath != nil {
		return *rq.resolvedPath
	}
	return rq.immutablePath
}
### Tasks
- [ ] confirm header works as expected or there is a bug (if so, fix it)
- [ ] add regression test to https://github.com/ipfs/gateway-conformance for the Example above

Metadata

Metadata

Assignees

Labels

need/triageNeeds initial labeling and prioritizationtopic/gatewayIssues related to HTTP Gateway

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions