id is a reserved field name

bear

I'm writing a provider for terraform to interface with an API, here's the resource schema I have:

&schema.Resource{
        Create: resourceProjectCreate,
        Read:   resourceProjectRead,
        Update: resourceProjectUpdate,
        Delete: resourceProjectDelete,
        Importer: &schema.ResourceImporter{
            State: schema.ImportStatePassthrough,
        },

        CustomizeDiff: customdiff.Sequence(
            customdiff.ComputedIf("slug", func(d *schema.ResourceDiff, meta interface{}) bool {
                return d.HasChange("name")
            }),
        ),

        Schema: map[string]*schema.Schema{
            "name": {
                Type:     schema.TypeString,
                Required: true,
                ValidateFunc: validateName,
            },
            "description": {
                Type:     schema.TypeString,
                Optional: true,
            },
            "issueManagementEnabled": {
                Type:     schema.TypeBool,
                Required: true,
            },
            "forkedFromId": {
                Type:     schema.TypeInt,
                Required: false,
            },
        },
    }

There are no compile or install errors with go install, and I'm trying this out locally, so I've set up my .terraformrc to point to my go bin folder.

Terraform seemingly finds an id somewhere, and complains:

Error: Internal validation of the provider failed! This is always a bug
with the provider itself, and not a user issue. Please report
this bug:

1 error occurred:
    * resource onedev_project: id is a reserved field name

The code is here https://github.com/UbiquitousBear/terraform-provider-onedev. Does anyone know where I should be removing the reference to id? It's not in the resource schema.

Martin Atkins

Your go.mod file suggests that you are using SDK version 1.17.2, where id is indeed recorded as a reserved attribute name.

However, it no longer seems to be present in the latest SDK release, 2.6.1. It seems that this policy changed as a result of issue #607, and the change was released for the first time in SDK release v2.1.0.

While I can't explain why the code you've shared would be raising that error, you may be able to avoid the problem by upgrading to the latest SDK version. Since it's a new major release there may be some breaking changes to consider elsewhere in the API. There's a Terraform SDK v2 upgrade guide which describes the changes and also includes a link to the tf-sdk-migrator tool which has some automation to help with the upgrade.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Struct field with reserved name golang

Creating field with reserved word name with JPA

Using the reserved word "class" as field name in Django and Django REST Framework

How to map an entity field whose name is a reserved word in JPA

Problems with reserved field name 'user' in SAS Proc SQL

Java reserved name compilation

Is "configuration" a reserved name?

Scala reserved word as JSON field name with Json.writes[A] (Play equivalent for @SerializedName)

Cosmos DB SQL API - How to query a field name that uses a reserved word

Is "register" a reserved keyword in Ksql and if so how can I select a field with that name

Yahoo YQL API - How to select a JSON field whose name is a reserved YQL keywords?

How to change the column name of a FK Id field?

Is it safe to name field as 'id' in Django model?

Foregin key field name is followed by _id

Dynamically name ID in number_field_tag

X++ Reserved Column Name?

Is it definitely illegal to refer to a reserved name?

Ansible variable name `environment` is reserved?

Use reserved word as prop name

Is it "javax" illegal(reserved) package name or not?

mongo - unique name field base on parent_id field

Update one document by _id (Invalid BSON field name _id)

Is there a way to change MongoDB _id field name in MongoEngine from $oid to $id?

Why is a JavaScript reserved keyword allowed as a variable name?

Is NS_SWIFT_NAME reserved to Factory methods?

typescript namespace declaration using a reserved name

TypeScript error: Reserved word 'this' used as name

How to use reserved keyword as the name of variable in python?

How to delete this kind of file using a reserved name?

TOP Ranking

  1. 1

    Failed to listen on localhost:8000 (reason: Cannot assign requested address)

  2. 2

    How to import an asset in swift using Bundle.main.path() in a react-native native module

  3. 3

    Loopback Error: connect ECONNREFUSED 127.0.0.1:3306 (MAMP)

  4. 4

    pump.io port in URL

  5. 5

    Spring Boot JPA PostgreSQL Web App - Internal Authentication Error

  6. 6

    BigQuery - concatenate ignoring NULL

  7. 7

    ngClass error (Can't bind ngClass since it isn't a known property of div) in Angular 11.0.3

  8. 8

    Do Idle Snowflake Connections Use Cloud Services Credits?

  9. 9

    maven-jaxb2-plugin cannot generate classes due to two declarations cause a collision in ObjectFactory class

  10. 10

    Compiler error CS0246 (type or namespace not found) on using Ninject in ASP.NET vNext

  11. 11

    Can't pre-populate phone number and message body in SMS link on iPhones when SMS app is not running in the background

  12. 12

    Generate random UUIDv4 with Elm

  13. 13

    Jquery different data trapped from direct mousedown event and simulation via $(this).trigger('mousedown');

  14. 14

    Is it possible to Redo commits removed by GitHub Desktop's Undo on a Mac?

  15. 15

    flutter: dropdown item programmatically unselect problem

  16. 16

    Change dd-mm-yyyy date format of dataframe date column to yyyy-mm-dd

  17. 17

    EXCEL: Find sum of values in one column with criteria from other column

  18. 18

    Pandas - check if dataframe has negative value in any column

  19. 19

    How to use merge windows unallocated space into Ubuntu using GParted?

  20. 20

    Make a B+ Tree concurrent thread safe

  21. 21

    ggplotly no applicable method for 'plotly_build' applied to an object of class "NULL" if statements

HotTag

Archive