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

Malformed username error not clear #1742

Open
mcountryman opened this issue Feb 4, 2025 · 0 comments
Open

Malformed username error not clear #1742

mcountryman opened this issue Feb 4, 2025 · 0 comments
Labels
🐛 bug Something isn't working

Comments

@mcountryman
Copy link

Describe the bug
When using a username/password login with a username that does not end with @* the error provided is not clear as to what the issue is. I was able to peek at the code to identify the issue so this is partially a submission to document what I found and partially because I may or may not try to make a PR if I have time.

To Reproduce
Steps to reproduce the behavior:

  1. Create a resource '....'
  2. Run '....'
  3. See error
  4. Modify the resource '....'
  5. Run '....'
  6. See error

Please also provide a minimal Terraform configuration that reproduces the issue.

terraform {
  required_providers {
    proxmox = {
      source = "bpg/proxmox"
      version = "0.70.1"
    }
  }
}

provider "proxmox" {
  endpoint = var.proxmox-endpoint
  username = "root" # Missing `@pam`
}

# Any sort of resource definition to kick off the provider.  I didn't get far
# enough to actually validate below works.
resource "proxmox_virtual_environment_download_file" "nixos_lxc_25_05" {
  content_type = "vztmpl"
  datastore_id = "local"
  node_name    = "first-node"
  url          = "https://hydra.nixos.org/build/287411733/download/1/nixos-system-x86_64-linux.tar.xz"
}

and the output of terraform|tofu apply.

> tofu plan --var-file=.tfvars

Planning failed. OpenTofu encountered an error while generating this plan.

╷
│ Error: Unable to create Proxmox VE API credentials
│
│   with provider["registry.opentofu.org/bpg/proxmox"],
│   on providers.tf line 10, in provider "proxmox":
│   10: provider "proxmox" {
│
│ must provide either user credentials, an API token, or a ticket

Expected behavior
An error indicating that user cred validation failed rather than wasn't supplied.

Additional context
This is probably the issue here:

usr, err := newUserCredentials(username, password, otp)

Looks like the validation logic and variable presence logic was merged leading to the need to throw away errors.

  • Single or clustered Proxmox: Irrelevant
  • Proxmox version: Irrelevant
  • Provider version (ideally it should be the latest version): 0.70.1
  • Terraform/OpenTofu version: Terraform v1.9.8/OpenTofu v1.8.7
  • OS (where you run Terraform/OpenTofu from): darwin_arm64
  • Debug logs (TF_LOG=DEBUG terraform apply):
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
Status: 📥 Inbox
Development

No branches or pull requests

1 participant