Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Read schema type hint from sync request #453

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

gammazero
Copy link
Collaborator

Read the schema type hint from the IPNI sync request header, and if provided, compare it against the type of data retrieved.

Head the schema type hint from the IPNI sync request header, and if provided, compare it against the type of data retrieved.
Comment on lines +67 to +81
if cidSchemaType != "" && cidSchemaType != ipnisync.CidSchemaAdvertisement {
log.Errorf("Retrieved advertisement when asked for %s", cidSchemaType)
return nil, errors.New("data does not match requested type")
}
log.Debugw("Retrieved advertisement from datastore", "cid", c, "size", len(val))
return bytes.NewBuffer(val), nil
}
log.Debugw("Retrieved non-advertisement object from datastore", "cid", c, "size", len(val))
}

if cidSchemaType != "" && cidSchemaType != ipnisync.CidSchemaEntryChunk {
log.Errorf("Asked for %s when expecting %s", cidSchemaType, ipnisync.CidSchemaEntryChunk)
return nil, errors.New("requested unexpected data type")
}

Copy link
Member

Choose a reason for hiding this comment

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

lets log these but not return an error?

if we got the right data that matches the cid, we should continue, not error

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants