none
Error in Configuration Validation in Workbench RRS feed

  • Question

  • Hi,

    I am getting this error while uploading my config file and not sure what it means exactly and how to fix it.

    {"Errors":["Configuration validation encountered unexpected error: Exception while validating input against type check"],"Warnings":[]}

    I am new to workbench and any help is appreciated.

    Thanks

    Monday, July 15, 2019 7:49 AM

Answers

  • Hi,

    Really Sorry for the late reply!

    I had only put the config file in the workbench and not the solidity file, so can't see any reason for it detecting errors in the solidity code.

    Also, I changed the config file a bit and added AllowedInstanceRoles, and it is now working. But don't know exactly what was causing the problem.

    This is the updated config file

    {
        "ApplicationName": "Election",
        "DisplayName": "Election",
        "Description": "Allows voters to vote securely for the candidate of their choice.",
        "ApplicationRoles": [
          {
            "Name": "ElectionCommission",
            "Description": "Organisation which administers the election process."
          },
          {
            "Name": "Voter",
            "Description": "User who can vote."
          }
        ],
        "Workflows": [
          {
            "Name": "Election",
            "DisplayName": "Election",
            "Description": "Handles the Voting process",
            "Initiators": [ "ElectionCommission" ],
            "StartState":  "Setup",
            "Properties": [
              {
                "Name": "State",
                "DisplayName": "State",
                "Description": "Holds the state of the contract",
                "Type": {
                  "Name": "state"
                }
              },
              {
                "Name": "ElectionCommission",
                "DisplayName": "Election Commission",
                "Description": "...",
                "Type": {
                  "Name": "ElectionCommission"
                }
              },
              {
                "Name": "Voter",
                "DisplayName": "Voter",
                "Description": "...",
                "Type": {
                  "Name": "Voter"
                }
              },
              {
                "Name": "CandidatesCount",
                "DisplayName": "Candidates Count",
                "Type": {
                  "Name": "int"
                }
              },
              {
                "Name": "cname",
                "DisplayName": "Candidate name",
                "Type": {
                  "Name": "string"
                }
              },
              {
                "Name": "candidateId",
                "DisplayName": "Candidate ID",
                "Type": {
                  "Name": "int"
                }
              },
              {
                "Name": "winner",
                "DisplayName": "Winner Of the Election",
                "Type": {
                  "Name": "string"
                }
              },
              {
                "Name": "Title",
                "DisplayName": "Title Of Election",
                "Type": {
                  "Name": "string"
                }
              }
            ],
            "Constructor": {
              "Parameters": [{
                "Name": "title",
                "Description": "Title of the Election",
                "DisplayName": "Title of Election",
                "Type": {
                  "Name": "string"
                }
              }]
            },
            "Functions": [
              {
                "Name": "AddCandidate",
                "DisplayName": "Add Candidate",
                "Description": "Add a Candidate contesting for the Election",
                "Parameters": [
                  {
                    "Name": "cname",
                    "Description": "Name of the Candidate",
                    "DisplayName": "Name",
                    "Type": {
                      "Name": "string"
                    }
                  }
                ]
              },
              {
                "Name": "vote",
                "DisplayName": "Vote",
                "Description": "Vote for a particular candidate",
                "Parameters": [{
                    "Name": "candidateId",
                    "Description": "Id of the Candidate",
                    "DisplayName": "Candidate ID",
                    "Type": {
                      "Name": "int"
                    }
                  
              }]
              },
              {
                "Name": "rescalc",
                "DisplayName": "Calculate Results",
                "Description": "Shows who won the election",
                "Parameters": []
              }
            ],
            "States": [
              {
                "Name": "Setup",
                "DisplayName": "Setup",
                "Description": "Setting Up Candidates",
                "PercentComplete": 20,
                "Style": "Success",
                "Transitions": [
                  {
                    "AllowedRoles": ["Voter"],
                    "AllowedInstanceRoles": ["Voter"],
                    "DisplayName": "Voting Period",
                    "Function": "vote",
                    "NextStates": ["Voting"]
                  },
                  {
                    "AllowedRoles": ["ElectionCommission"],
                    "AllowedInstanceRoles": ["ElectionCommission"],
                    "DisplayName": "Add Candidates",
                    "Function": "AddCandidate",
                    "NextStates": ["Setup"]
                  }
                ]
              },
              {
                "Name": "Voting",
                "DisplayName": "Voting",
                "Description": "Vote for your Candidate",
                "PercentComplete": 60,
                "Style": "Success",
                "Transitions": [
                  {
                  "AllowedRoles": ["ElectionCommission"],
                  "AllowedInstanceRoles": ["ElectionCommission"],
                  "DisplayName": "Results",
                  "Function": "rescalc",
                  "NextStates": ["Result"]
                },
                {
                  "AllowedRoles": ["Voter"],
                  "AllowedInstanceRoles": ["Voter"],
                  "DisplayName": "Vote",
                  "Function": "vote",
                  "NextStates": ["Voting"]
                }
              ]
              },
              {
                "Name": "Result",
                "DisplayName": "Results",
                "Description": "See the Results",
                "PercentComplete": 100,
                "Style": "Success",
                "Transitions": []
              }
            ]
          }
        ]   
      }

    A few changes have been made according to the requirement but don't know what was causing the problem initially.

    Sunday, July 28, 2019 8:45 PM

All replies

  • Hi,

    Thanks for trying out Azure Blockchain Workbench!

    There seems to have been an error when doing a type check against your configuration file. Could you post your config file so we can figure out what the root cause is?


    Microsoft Azure Blockchain Team

    Monday, July 15, 2019 9:36 AM
    Owner
  • {

    "ApplicationName": "Election", "DisplayName": "Election", "Description": "Allows voters to vote securely for the candidate of their choice.", "ApplicationRoles": [ { "Name": "ElectionCommission", "Description": "Organisation which administers the election process." }, { "Name": "Voter", "Description": "User who can vote." } ], "Workflows": [ { "Name": "Election", "DisplayName": "Election", "Description": "Handles the Voting process", "Initiators": [ "ElectionCommission" ], "StartState": "Voting", "Properties": [ { "Name": "State", "DisplayName": "State", "Description": "Holds the state of the contract", "Type": { "Name": "state" } }, { "Name": "candidatesCount", "DisplayName": "Candidates Count", "Type": { "Name": "int" } }, { "Name": "winner", "DisplayName": "Winner", "Type": { "Name": "string" } }, { "Name": "_name", "DisplayName": "Candidate name", "Type": { "Name": "string" } }, { "Name": "_candidateId", "DisplayName": "Candidate ID", "Type": { "Name": "int" } } ], "Constructor": { "Parameters": [] }, "Functions": [ { "Name": "addCandidate", "DisplayName": "Add Candidate", "Description": "Add a Candidate contesting for the Election", "Parameters": [ { "Name": "_name", "Description": "Name of the Candidate", "DisplayName": "Name", "Type": { "Name": "string" } } ] }, { "Name": "vote", "DisplayName": "Vote", "Description": "Vote for a particular candidate", "Parameters": [{ "Name": "_candidateId", "Description": "Id of the Candidate", "DisplayName": "Candidate ID", "Type": { "Name": "int" } } ] }, { "Name": "res_calc", "DisplayName": "Calculate Results", "Description": "Shows who won the election", "Parameters": [] } ], "States": [ { "Name": "Voting", "DisplayName": "Voting", "Description": "Voting allowed", "PercentComplete": 40, "Style": "Success", "Transitions": [{ "AllowedRoles": ["ElectionCommission"], "DisplayName": "Results", "Function": "res_calc", "NextStates": ["Result"] }] }, { "Name": "Result", "DisplayName": "Results", "Description": "See the Results", "PercentComplete": 100, "Style": "Success", "Transitions": [] } ] } ] }

    Monday, July 15, 2019 10:48 AM
  • Hi,

    Thanks for trying out Azure Blockchain Workbench!

    There seems to have been an error when defining the state type enum in your solidity code. Could you please provide your solidity code corresponding to this config file as well so we can figure out what the root cause is?


    Microsoft Azure Blockchain Team

    Monday, July 22, 2019 9:48 PM
    Owner
  • Hi Manikyab,

    Please share with us the information requested or let us know if you are not blocked anymore.

    Thank you!

    Friday, July 26, 2019 6:21 PM
    Moderator
  • Hi,

    Really Sorry for the late reply!

    I had only put the config file in the workbench and not the solidity file, so can't see any reason for it detecting errors in the solidity code.

    Also, I changed the config file a bit and added AllowedInstanceRoles, and it is now working. But don't know exactly what was causing the problem.

    This is the updated config file

    {
        "ApplicationName": "Election",
        "DisplayName": "Election",
        "Description": "Allows voters to vote securely for the candidate of their choice.",
        "ApplicationRoles": [
          {
            "Name": "ElectionCommission",
            "Description": "Organisation which administers the election process."
          },
          {
            "Name": "Voter",
            "Description": "User who can vote."
          }
        ],
        "Workflows": [
          {
            "Name": "Election",
            "DisplayName": "Election",
            "Description": "Handles the Voting process",
            "Initiators": [ "ElectionCommission" ],
            "StartState":  "Setup",
            "Properties": [
              {
                "Name": "State",
                "DisplayName": "State",
                "Description": "Holds the state of the contract",
                "Type": {
                  "Name": "state"
                }
              },
              {
                "Name": "ElectionCommission",
                "DisplayName": "Election Commission",
                "Description": "...",
                "Type": {
                  "Name": "ElectionCommission"
                }
              },
              {
                "Name": "Voter",
                "DisplayName": "Voter",
                "Description": "...",
                "Type": {
                  "Name": "Voter"
                }
              },
              {
                "Name": "CandidatesCount",
                "DisplayName": "Candidates Count",
                "Type": {
                  "Name": "int"
                }
              },
              {
                "Name": "cname",
                "DisplayName": "Candidate name",
                "Type": {
                  "Name": "string"
                }
              },
              {
                "Name": "candidateId",
                "DisplayName": "Candidate ID",
                "Type": {
                  "Name": "int"
                }
              },
              {
                "Name": "winner",
                "DisplayName": "Winner Of the Election",
                "Type": {
                  "Name": "string"
                }
              },
              {
                "Name": "Title",
                "DisplayName": "Title Of Election",
                "Type": {
                  "Name": "string"
                }
              }
            ],
            "Constructor": {
              "Parameters": [{
                "Name": "title",
                "Description": "Title of the Election",
                "DisplayName": "Title of Election",
                "Type": {
                  "Name": "string"
                }
              }]
            },
            "Functions": [
              {
                "Name": "AddCandidate",
                "DisplayName": "Add Candidate",
                "Description": "Add a Candidate contesting for the Election",
                "Parameters": [
                  {
                    "Name": "cname",
                    "Description": "Name of the Candidate",
                    "DisplayName": "Name",
                    "Type": {
                      "Name": "string"
                    }
                  }
                ]
              },
              {
                "Name": "vote",
                "DisplayName": "Vote",
                "Description": "Vote for a particular candidate",
                "Parameters": [{
                    "Name": "candidateId",
                    "Description": "Id of the Candidate",
                    "DisplayName": "Candidate ID",
                    "Type": {
                      "Name": "int"
                    }
                  
              }]
              },
              {
                "Name": "rescalc",
                "DisplayName": "Calculate Results",
                "Description": "Shows who won the election",
                "Parameters": []
              }
            ],
            "States": [
              {
                "Name": "Setup",
                "DisplayName": "Setup",
                "Description": "Setting Up Candidates",
                "PercentComplete": 20,
                "Style": "Success",
                "Transitions": [
                  {
                    "AllowedRoles": ["Voter"],
                    "AllowedInstanceRoles": ["Voter"],
                    "DisplayName": "Voting Period",
                    "Function": "vote",
                    "NextStates": ["Voting"]
                  },
                  {
                    "AllowedRoles": ["ElectionCommission"],
                    "AllowedInstanceRoles": ["ElectionCommission"],
                    "DisplayName": "Add Candidates",
                    "Function": "AddCandidate",
                    "NextStates": ["Setup"]
                  }
                ]
              },
              {
                "Name": "Voting",
                "DisplayName": "Voting",
                "Description": "Vote for your Candidate",
                "PercentComplete": 60,
                "Style": "Success",
                "Transitions": [
                  {
                  "AllowedRoles": ["ElectionCommission"],
                  "AllowedInstanceRoles": ["ElectionCommission"],
                  "DisplayName": "Results",
                  "Function": "rescalc",
                  "NextStates": ["Result"]
                },
                {
                  "AllowedRoles": ["Voter"],
                  "AllowedInstanceRoles": ["Voter"],
                  "DisplayName": "Vote",
                  "Function": "vote",
                  "NextStates": ["Voting"]
                }
              ]
              },
              {
                "Name": "Result",
                "DisplayName": "Results",
                "Description": "See the Results",
                "PercentComplete": 100,
                "Style": "Success",
                "Transitions": []
              }
            ]
          }
        ]   
      }

    A few changes have been made according to the requirement but don't know what was causing the problem initially.

    Sunday, July 28, 2019 8:45 PM
  • Greetings,

    The error was caused by not having the "AllowedInstanceRoles" as you have correctly pointed out.  The reason is because "AllowedInstanceRoles" property is used by Workbench to enforce specific role-based access to functions in the smart contract. 

    "AllowedInstanceRoles" is a little different from "AllowedRoles".  Here is an illustration.  Consider two functions "Buy" and "Negotiate", where "Negotiate" can only be called after "Buy" and by the person who called the function "Buy".  Now since any one can call "Buy", you only set "AllowedRoles" for "Buy", may be the role "Buyer".  Note, however, since not everyone can call negotiate and only the buyer who has called "Buy", you only set "AllowedInstanceRoles" for the "Negotiate" function.  Please note that if you also set the "AllowedRoles" in the Negotiate function, then any one in that role can call the negotiate function; and, that is not the intended behavior in this example.

    Please find more information on the Configuration file here https://docs.microsoft.com/en-us/azure/blockchain/workbench/configuration.  Please let us know if you have any other questions.

    Thanks.


    Microsoft Azure Blockchain Team


    Monday, August 12, 2019 4:54 PM
    Owner