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

Cannot Create Document type Items because File.content is not exported #45

Closed
snarlysodboxer opened this issue Feb 15, 2022 · 6 comments
Labels
bug Something isn't working

Comments

@snarlysodboxer
Copy link
Contributor

Your environment

SDK Version: 1.2.0
Connect Server Version: 1.5.0
OS: MacOS
Go Version: 1.17.2

What happened?

File.content is not exported, so when calling Client.CreateItem(item) on an item with Files, the file's contents are left out by json.Marshal(item).

Here's how how I'm calling CreateItem

	// TODO generate random IDs?
	vaultID := "fdsasdkfjsdkfjhsd" // retrieved first
	itemName := "my-item"
	itemID := fmt.Sprintf("%s-id", itemName)
	fileName := "my-file.txt"
	fileID := fmt.Sprintf("%s-id", fileName)
	contents, err := os.ReadFile(fileName)
	if err != nil {
		return err
	}

	contentPath := fmt.Sprintf("v1/vaults/%s/items/%s/files/%s/content", vaultID, itemID, fileID)
	file := &onepassword.File{
		ID:          fileID,
		Name:        fileName,
		Size:        len(contents),
		ContentPath: contentPath,
	}
	file.SetContent(contents)

	item := &onepassword.Item{
		ID:       itemID,
		Title:    itemName,
		Vault:    onepassword.ItemVault{ID: vaultID},
		Category: onepassword.Document,
		Files:    []*onepassword.File{file},
	}

	_, err = client.CreateItem(item, vaultID)
	if err != nil {
		return err
	}
@snarlysodboxer
Copy link
Contributor Author

snarlysodboxer commented Feb 15, 2022

Using the above code against the the fix in mentioned PR, the content is now in the output of json.Marshal, however the API still returns Error: status 400: Validation: (validateVaultItem failed to Validate), Couldn't validate the item: "[ItemValidator] has found 1 errors, 0 warnings: \nErrors:{1. Field of unexpected type \"\" at \"item.details.documentAttributes\". Requires one of [\"object\"]}". There's no item.details.documentAttributes in the code or object schemas.

@snarlysodboxer
Copy link
Contributor Author

Anyone there?

@edif2008
Copy link
Member

Hey @snarlysodboxer,

Apologies for this late reply.

Unfortunately, at the moment, Connect does not support creating items with files in them. There is no API endpoint that supports this at the moment. Therefore, it's not possible to create Document type items with Connect. You can only fetch them.

However, we have this feature in our backlog, and we will let you know when this feature comes up.
When the new API endpoint will be up, we will update all our SDKs properly, so that you will be able to create Document type items with Connect using this SDK.

Thank you for your patience.

@snarlysodboxer
Copy link
Contributor Author

@edif2008 Thanks for the reply. It's a relief to know you plan to continue to support this client. We just built a 1Password provider using this client and contributed it to the popular project external-secrets.io. (The usage of this client is all in pkg/provider/onepassword/onepassword.go in case you're curious.)

They're going to cut a new release with 1Password support tomorrow, for now it can be seen here. If you search the word "bug" on that page, you'll see this self-same git issue mentioned. (Sorry, I thought it was a bug not just unimplemented.) You might also notice on this issue that there are a number of companies lining up to use 1Password with the external-secrets operator.

We have noticed some problems with the Connect Server that force us to restart it semi-frequently. - Should we submit issues about that at https://github.com/1Password/connect? Or somewhere else?

@edif2008
Copy link
Member

Hey @snarlysodboxer,

I've taken a quick look at the provider you mentioned and it's quite interesting. It's exciting to see that this SDK brings value to other products! 🎉

We have noticed some problems with the Connect Server that force us to restart it semi-frequently. - Should we submit issues about that at https://github.com/1Password/connect? Or somewhere else?

Definitely open an issue on that repo, along with some logs so that we can better understand what causes you to restart the server. In this way, we can identify the problem faster and, if applicable, come up with the proper fix for it.

@snarlysodboxer
Copy link
Contributor Author

snarlysodboxer commented May 26, 2022

Hope it's ok, I've opened a new issue to track this need since the direction of this particular issue no longer makes sense given the feedback.

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

No branches or pull requests

2 participants