{ Community }
  • Academy
  • Docs
  • Developers
  • Resources
    • Community Articles
    • Apigee on GitHub
    • Code Samples
    • Videos & eBooks
    • Accelerator Methodology
  • Support
  • Ask a Question
  • Spaces
    • Product Announcements
    • General
    • Edge/API Management
    • Developer Portal (Drupal-based)
    • Developer Portal (Integrated)
    • API Design
    • APIM on Istio
    • Extensions
    • Business of APIs
    • Academy/Certification
    • Adapter for Envoy
    • Analytics
    • Events
    • Hybrid
    • Integration (AWS, PCF, Etc.)
    • Microgateway
    • Monetization
    • Private Cloud Deployment
    • 日本語コミュニティ
    • Insights
    • IoT Apigee Link
    • BaaS/Usergrid
    • BaaS Transition/Migration
    • Apigee-127
    • New Customers
    • Topics
    • Questions
    • Articles
    • Ideas
    • Leaderboard
    • Badges
  • Log in
  • Sign up

Get answers, ideas, and support from the Apigee Community

  • Home /
  • Edge/API Management /
avatar image
1
Question by Hari · May 27, 2016 at 03:09 PM · 570 Views variablenames

A variable called var.colour is fine, but creating another one called var.colour.again is not. Why is that?

I am using an Extract Variable policy to extract a query parameter and save it in a variable called 'var.colour'. If I try to extract the same query parameter (or even a different one, it doesn't matter) into another variable called 'var.colour.hue', Apigee does not set the second variable and returns an error. This is what we see in the trace:

As you notice, Apigee has no issue in saving the variable named 'var.colour1'. Also, none of these variables would be created if there were another variable called 'var'.

Below is the error we see.

{
    "fault": {
        "faultstring": "Failed to set variable var.colour.again value blue from ExtractVariables: Extract-Variable",
        "detail": {
            "errorcode": "steps.extractvariables.SetVariableFailed"
        }
    }
}

So basically, I can name a variable with a dot in the name (e.g. variable.name) without any issues, but if another variable name contains the same variable name in it (e.g. variable.name.1), it fails.

I found this by accident and saw that this has not been documented in Apigee Docs. Can someone validate this and confirm if this is an issue or if this is by design?

apigeevariable.png (12.8 kB)
Comment
Add comment
10 |5000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by Apigeeks only
  • Viewable by the original poster
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Close

1 Answer

  • Sort: 
avatar image
3
Best Answer

Answer by yuriyl · Jun 21, 2016 at 12:24 PM

Here are some findings on how the dot-notation work in Apigee Edge implementation and mechanics of the original post's failures.

The doc on http://docs.apigee.com/api-services/content/introduction-flow-variables says:

"dot-notation convention is strictly for naming purposes. For example, request.content does not refer to a parent variable or object called "request"."

It is not technically correct. Internally, variables dot notation is implemented in a tree-like structure.

When assigned, a variable name is parsed into dot-separated tokens and non-leaf elements are stored as Java maps. Leaf tokens will be an object type.

When accessed, the dot-separated name goes through a similar recursive process and all non-leaf nodes expect to encounter a map, containing either next 'path' element or a leaf object.

A first assignment would define a type of a node. Therefore, all consecutive assignments/retrievals shall respect the originally assigned type.

For example, if you create/assign

node1.leaf

then your leaf is an object node. Therefore, following assign

node1.node2.leaf will fail as it is impossible to allocate map node2, because leaf is already allocated.

As we are talking about a recursive variable name parsing function, the same applies for deeply nested dot.separated names:

node1.node2.node3.node4.leaf

will work, but the following assignment

node1.node2.node3.node4.node5.leaf

will fail.

While accessing variables, during path traversal retrieval process checks if nodes are maps and if they are not, silently fails, by returning nothing. As a result, we can see that not-equal Unicode character and are left puzzled by the behaviour.

In a nutshell: a success of using variables defined with dot notation is dependent on an order of creation of the variables.

Attn: @Hari

Comment
Add comment · Link
10 |5000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by Apigeeks only
  • Viewable by the original poster
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Follow this Question

Answers Answers and Comments

34 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

is there a flow variable for application name which can be used in javascript policy ? 2 Answers

Can i use a Variable for the value StripLevels in the XMLToJSON policy 2 Answers

Can Service Callout Policy / be configured using Variables? 1 Answer

Is there a way I can convert seconds to milliseconds in an Extract Variable Policy? 1 Answer

Changing name of Environment 3 Answers

  • Products
    • Edge - APIs
    • Insights - Big Data
    • Plans
  • Developers
    • Overview
    • Documentation
  • Resources
    • Overview
    • Blog
    • Apigee Institute
    • Academy
    • Documentation
  • Company
    • Overview
    • Press
    • Customers
    • Partners
    • Team
    • Events
    • Careers
    • Contact Us
  • Support
    • Support Overview
    • Documentation
    • Status
    • Edge Support Portal
    • Privacy Policy
    • Terms & Conditions
© 2021 Apigee Corp. All rights reserved. - Apigee Community Terms of Use - Powered by AnswerHub
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Create an article
  • Post an idea
  • Spaces
  • Product Announcements
  • General
  • Edge/API Management
  • Developer Portal (Drupal-based)
  • Developer Portal (Integrated)
  • API Design
  • APIM on Istio
  • Extensions
  • Business of APIs
  • Academy/Certification
  • Adapter for Envoy
  • Analytics
  • Events
  • Hybrid
  • Integration (AWS, PCF, Etc.)
  • Microgateway
  • Monetization
  • Private Cloud Deployment
  • 日本語コミュニティ
  • Insights
  • IoT Apigee Link
  • BaaS/Usergrid
  • BaaS Transition/Migration
  • Apigee-127
  • New Customers
  • Explore
  • Topics
  • Questions
  • Articles
  • Ideas
  • Badges