Skip to content

Conversation

@speto
Copy link

@speto speto commented Feb 12, 2025

I believe part of the problem with the credential category lies in if f.ID == "credential" && item.Category == "API_CREDENTIAL" where "credential" is checked against f.ID.

I'm not sure if I'm following correctly everything, but I believe the correct f field for this comparison should be Label not ID. Leaving it like rest of the fields on 350-362 should be sufficient.

I followed discussion in the original PR but I don't feel much clearer on it. Just think this shouldn't have been merged without tests.

So, first I added a test for credential category, which successfully failed. Then I tried fixing the issue and discovered the f.ID problem. Afterwards I added additional credential fields based on what 1password returns for that category and updated the docs. The type field is shared between both database and credential category.

This is also related to #52

@github-actions
Copy link
Contributor

⚠️ This PR contains unsigned commits. To get your PR merged, please sign those commits (git rebase --exec 'git commit -S --amend --no-edit -n' @{upstream}) and force push them to this branch (git push --force-with-lease).

If you're new to commit signing, there are different ways to set it up:

Sign commits with gpg

Follow the steps below to set up commit signing with gpg:

  1. Generate a GPG key
  2. Add the GPG key to your GitHub account
  3. Configure git to use your GPG key for commit signing
Sign commits with ssh-agent

Follow the steps below to set up commit signing with ssh-agent:

  1. Generate an SSH key and add it to ssh-agent
  2. Add the SSH key to your GitHub account
  3. Configure git to use your SSH key for commit signing
Sign commits with 1Password

You can also sign commits using 1Password, which lets you sign commits with biometrics without the signing key leaving the local 1Password process.

Learn how to use 1Password to sign your commits.

Watch the demo

- Introduced TestAccItemDataSourceApiCredential to verify the retrieval of API credential as an item from the data source.
- Added utility functions for generating test API credential items and fields.
- Correctly assigns credential field values during item data source processing.
- Removes redundant logic that incorrectly parsed "credential" fields.
Add support for `valid_from`, `expires`, and `filename` fields in the `API_CREDENTIAL` category. Update documentation and internal descriptions to reflect these additions, ensuring consistent handling of API credential metadata.
@JillRegan
Copy link
Contributor

Hi @speto 👋 I just tried to reproduce this issue and was able to access the credential field of an API Credential. It looks like this was resolved in version 2.1.0.

I am going to close this PR but if you continue to encounter any more issues please tag me with some context and I can reopen!

@JillRegan JillRegan closed this Dec 4, 2025
@speto
Copy link
Author

speto commented Dec 4, 2025

Thanks @JillRegan.

While the credential field is accessible now, I believe the current implementation is incomplete and inconsistent with the codebase.

The condition if f.ID == "credential" && item.Category == "API_CREDENTIAL" breaks the parsing pattern of the immediate context. The rest of the logic handles fields via a switch statement. Injecting a specific if block for one category/field combination is technical debt that makes the parsing logic harder to read and maintain.

API_CREDENTIAL items are not just about the credential field. They specifically define filename, valid_from, and expires as well. My PR mapped these fields correctly. The current implementation misses them entirely.

Eventually, this should be addressed to align the parsing logic and include the missing fields.

@JillRegan
Copy link
Contributor

Thank you for your feedback, @speto. I appreciate you pointing out these issues.

I'm going to reopen this PR for review. We've added E2E tests since the PR was originally opened so we will want to look at adding testing there for these updates.

We're planning to address some open issues in the Terraform Provider over the coming weeks, and I'll try to address these updates/concerns as part of that work. I can take a closer look at these changes once we tackle some existing bugs. 👍

@JillRegan JillRegan reopened this Dec 5, 2025
@JillRegan JillRegan added the enhancement New feature or request label Dec 5, 2025
@JillRegan JillRegan self-assigned this Dec 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants