Playbook: debug config and environment

The question, in the user's words: "This call works on my machine and fails in staging. Where does its address come from, which settings does this service read, and does Niro know their values?"

What you get at the end: every setting a folder's code reads, where each is read, whether Niro has a value for it, and the lines in config files that set it, with secrets masked.

Words used on this page: a setting is a named value the code reads at run time, from an environment variable or a config file; a base address is the scheme://host:port a service is reached at.

The steps

1. Which settings does the code read?

niro env list --path main

  BASE_URL              http://localhost:8100  computed
  shop.orders.base-url  no value  main/src/main/java/com/example/shop/main/http/RestTemplateCalls.java:15

Each line is a setting, its value, and who set it ("computed" means Niro worked it out). shop.orders.base-url is read by @Value("${shop.orders.base-url}") at line 15, and Niro holds no value for it.

2. Where is it set?

code_grep also searches config, build and deploy files, with values masked:

niro ask code_grep pattern="base-url" answer=locations

4 matching lines in 3 files
main/src/main/java/com/example/shop/main/http/RestTemplateCalls.java:15
main/EXPECTED.json:112
main/EXPECTED.json:168
main/src/main/resources/application.yml:5

Reading the config lines themselves shows the value, and masks what looks like a secret:

niro ask code_grep pattern="base-url|password" path_pattern=main/src/main/resources/ match_mode=regex

[{"file":".../main/src/main/resources/application.yml","matches":[
  {"line":5,"text":"    base-url: http://orders-api:8101"},
  {"line":15,"text":"    password: <MASK_SECRET_002>"}],"truncated":false}]

In this run application.yml sets the value, but niro env list still said "no value". Give Niro the value for the environment you are debugging, so its links follow that environment:

niro env set shop.orders.base-url=http://orders-api:8101
niro build

Niro refuses to store passwords and tokens: a graph needs addresses and names, not secrets.

3. Which calls have no address, or two possible targets?

niro route-rule unconnected

5 address(es) dialled that no service here answers on:
  http://gift-cards-api:8113: 1 call(s) from java-mono/main; no service here declares their paths
  ...
1 call(s) name no address in the source, and no service here declares their path.
  java-mono/main GET /{param}

"No service here answers" means the address points outside the indexed code, or the address is wrong. "Name no address" means the URL is built from a setting or a variable Niro has no value for. The failing-call playbook shows how one rule settles a route two services declare: Playbook: debug a failing call between services.

Why the answer is complete, and where it is not

What grep would do instead

grep finds shop.orders.base-url too. It does not say which calls use it, whether two services answer the path, or which addresses no service answers, and it prints password: CHANGEME in plain text, where code_grep prints <MASK_SECRET_002>.

Cost

The value of this playbook is the lists grep cannot make (unconnected calls, values Niro holds), not token savings. What these steps cost depends on your code and your question. How Niro counts the size of its answers, and how to measure the cost on your own tasks, is in Tokens, speed and accuracy.

Configure a folder (env values, base address, route rules), Secrets and masking, Engine commands.