Xdebug is not launched in WSL2 in a docker CakePHP 3 application - xdebug

I am struggling with Xdebug + WSL2 + CakePHP 3 + VSCode. Checking the debug console it seems that I have running Xdebug correctly, but when I run a script in the browser, the Xdebug is not launched. This is the code:
Note: I forgot to mention that I am working on docker, that's why the "0.0.0.0" in the hostname parameter.
This is the xdebug.ini
zend_extension=xdebug
[xdebug]
zend_extension=xdebug
xdebug.mode=develop,debug
xdebug.client_host='host.docker.internal'
xdebug.start_with_request=yes
xdebug.client_port = 9003
xdebug.start_with_request=yes
xdebug.log=/var/log/xdebug/xdebug.log
xdebug.connect_timeout_ms=2000
launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Listen for Xdebug",
"type": "php",
"request": "launch",
"port": 9003,
"hostname": "0.0.0.0",
"pathMappings": {
"/webroot": "${workspaceRoot}"
},
"log": true
},
{
"name": "Launch currently open script",
"type": "php",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}",
"port": 0,
"runtimeArgs": [
"-dxdebug.start_with_request=yes"
],
"env": {
"XDEBUG_MODE": "debug,develop",
"XDEBUG_CONFIG": "client_port=${port}"
}
},
{
"name": "Launch Built-in web server",
"type": "php",
"request": "launch",
"runtimeArgs": [
"-dxdebug.mode=debug",
"-dxdebug.start_with_request=yes",
"-S",
"localhost:0"
],
"program": "",
"cwd": "${workspaceRoot}",
"port": 9003,
"serverReadyAction": {
"pattern": "Development Server \\(http://localhost:([0-9]+)\\) started",
"uriFormat": "http://localhost:%s",
"action": "openExternally"
}
}
]
}
This is the debug console:
Listening on { address: '0.0.0.0', family: 'IPv4', port: 9003 }
<- launchResponse
Response {
seq: 0,
type: 'response',
request_seq: 2,
command: 'launch',
success: true
}
<- initializedEvent
InitializedEvent { seq: 0, type: 'event', event: 'initialized' }
-> setBreakpointsRequest
{
command: 'setBreakpoints',
arguments: {
source: {
name: 'index.php',
path: '/root/server/webroot/index.php'
},
lines: [ 40 ],
breakpoints: [ { line: 40 } ],
sourceModified: false
},
type: 'request',
seq: 3
}
<- setBreakpointsResponse
Response {
seq: 0,
type: 'response',
request_seq: 3,
command: 'setBreakpoints',
success: true,
body: {
breakpoints: [
{
verified: true,
line: 40,
source: {
name: 'index.php',
path: '/root/server/webroot/index.php'
},
id: 1
}
]
}
}
The xdebug.log file
[20] Log opened at 2022-05-16 04:42:03.776649
[20] [Step Debug] INFO: Connecting to configured address/port: host.docker.internal:9003.
[20] [Step Debug] INFO: Connected to debugging client: host.docker.internal:9003 (through xdebug.client_host/xdebug.client_port). :-)
[20] [Step Debug] -> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" fileuri="file:///var/www/html/webroot/info.php" language="PHP" xdebug:language_version="7.4.19" protocol_version="1.0" appid="20"><engine version="3.1.2"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[https://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2021 by Derick Rethans]]></copyright></init>
[20] [Step Debug] <- feature_set -i 1 -n resolved_breakpoints -v 1
[20] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="1" feature="resolved_breakpoints" success="1"></response>
[20] [Step Debug] <- run -i 12
[20] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="run" transaction_id="12" status="stopping" reason="ok"></response>
[20] [Step Debug] <- stop -i 13
[20] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="stop" transaction_id="13" status="stopped" reason="ok"></response>
[20] Log closed at 2022-05-16 04:42:03.812679
UPDATE: Following this suggestion (I got from this link, by HolyGonzo) https://www.reddit.com/r/PHPhelp/comments/rqiw4h/need_help_troubleshooting_xdebug_configuration/ I added xdebug_break(); to my code, and then the debugger started working. It is pretty clear to understand that the issue it is in the VSCode configuration not in Xdebug.

SOLUTION:
After fight with this thing a few days, finally I found the issue:
In the launch.json in VSCode I updated this line and it works!!! (note that my path was wrong :( I had this "/var/www/webroot" instead of "/var/www/html/webroot").
"pathMappings": {
"/var/www/html/webroot": "${workspaceFolder}/webroot"
},
Update:
In order to allows Xdebug to look into the vendors folder, and the other folders outside /webroot, the code needs to be upated as follows (in my case, regarding to my server paths):
{
"name": "Listen for Xdebug",
"type": "php",
"request": "launch",
"port": 5902,
"hostname": "localhost",
"pathMappings": {
"/var/www/html": "${workspaceFolder}"
},
"log": true
}

Related

Using Volttron aggregation agent

I'm trying to get the aggregate agent to work with timescale db.
https://volttron.readthedocs.io/en/main/developing-volttron/developing-agents/specifications/aggregate.html
I have a file aggregation.config
{
"connection": {
"type": "postgresql",
"params": {
"dbname": "volttrondb",
"host": "127.0.0.1",
"port": 5432,
"user": "user",
"password": "password",
"timescale_dialect": true
}
},
"aggregations":[
# list of aggregation groups each with unique aggregation_period and
# list of points that needs to be collected
{
"aggregation_period": "1h",
"use_calendar_time_periods": true,
"utc_collection_start_time":"2016-03-01T01:15:01.000000",
"points": [
{
"topic_names": ["campus/building/fake/EKG_Cos", "campus/building/fake/EKG_Sin"],
"aggregation_topic_name":"campus/building/fake/avg_of_EKG_Cos_EKG_Sin",
"aggregation_type": "avg",
"min_count": 2
}
]
}
]
}
And run the following command
vctl install services/core/SQLAggregateHistorian/ --tag aggregate-historian -c config/aggregation.config --start
It starts correctly - the vctl status shows it running and there are no errors in the log.
I do not see the point campus/building/fake/avg_of_EKG_Cos_EKG_Sin in the topics table.
Any suggestions?

You do not have permission to use blocking webRequest listeners. Be sure to declare the webRequestBlocking permission in your manifest

I try to develop my first chrome extension with react js. when I try to blocking a URL in the chrome extension using chrome.webRequest API In error page shows two errors.
'webRequestBlocking' requires manifest version of 2 or lower.
Unchecked runtime.lastError: You do not have permission to use blocking webRequest listeners. Be sure to declare the webRequestBlocking permission in your manifest.
and I'm declaring the "webRequestBlocking" permission in the manifest file. here is my manifest.json
{
"manifest_version": 3,
"name": "Chrome Extension",
"description": "First Extension",
"options_page": "options.html",
"background": {
"service_worker": "background.bundle.js",
"matches": [
"<all_urls>"
]
},
"action": {
"default_title": "Open Extension",
"default_icon": "icon-34.png"
},
"icons": {
"128": "icon-128.png"
},
"content_scripts": [
{
"matches": [
"http://*/*",
"https://*/*",
"<all_urls>"
],
"js": [
"contentScript.bundle.js"
],
"css": [
"content.styles.css"
]
}
],
"devtools_page": "devtools.html",
"web_accessible_resources": [
{
"resources": [
"content.styles.css",
"icon-128.png",
"icon-34.png"
],
"matches": []
}
],
"permissions": [
"activeTab",
"tabs",
"webRequest",
"webRequestBlocking"
],
"host_permissions": [
"<all_urls>"
]
}
here is my background.js
chrome.webRequest.onBeforeRequest.addListener(
function(details) {
console.log(details);
return {cancel: true};
},
{urls: ["https://reactjs.org/"]},
["blocking"]
);
and I have tried removing webRequestBlocking but also the same. can anyone help me is there a way to fix this?
the error explains it self 'webRequestBlocking' requires manifest version of 2 or lower. so you can't use webRequestBlocking in manifest version 3 .
but chrome is giving an alternative by using declarativeNetRequestWithHostAccess API witch is used to block or modify network requests by specifying declarative rules
you can check here for more details .
You can change manifest_version to 2 and webRequestBlocking to permissions.

Cannot read property 'tenant_id' of undefined using Auth0

I've been setting up Single Sign On with Active Directory for our application according to this instruction:
https://auth0.com/docs/authenticate/identity-providers/enterprise-identity-providers/azure-active-directory/v2#register-your-app-with-azure-ad
However, after redirect to the Microsoft page i get this error:
Cannot read property 'tenant_id' of undefined
In my Auth0 Dashboard under
Monitoring > Logs
i found this error log:
{
"date": "2022-02-28T09:05:51.484Z",
"type": "f",
"description": "Cannot read property 'tenant_id' of undefined",
"connection_id": "",
"client_id": "XXXXXXX",
"client_name": "XXXXXXX (DEV)",
"ip": "195.192.198.XXX",
"user_agent": "Chrome 98.0.4758 / Mac OS X 10.15.7",
"details": {
"body": {},
"qs": {
"client_id": "XXXXXXXX",
"redirect_uri": "http://localhost:3000",
"scope": "openid profile email",
"response_type": "code",
"response_mode": "query",
"state": "WmdOOEpBTUlKTG5mQks1LjJLY3JabEwyUVBJTDZNeTdVZE1TZjNGVDhFUw==",
"nonce": "OG94dlNjbEFyUDJXcnNmeWNEamhSa1IxWHVSV08wcUxZS0tVQ3NwTjRjWA==",
"code_challenge": "8tWkNmx5qUlDVpIUCJy68B1lWwPa6qi1ZpMjq-4WZAc",
"code_challenge_method": "S256",
"auth0Client": "XXXXXXXXXX"
},
"error": {
"message": "Cannot read property 'tenant_id' of undefined",
"oauthError": "access_denied",
"type": "oauth-authorization"
},
"session_id": "7aXIltPAKa0e0vQhqyyAblzIWjmvbiy",
"riskAssessment": {
"confidence": "high",
"version": "1",
"assessments": {
"UntrustedIP": {
"confidence": "high",
"code": "not_found_on_deny_list"
},
"NewDevice": {
"confidence": "high",
"code": "initial_login"
},
"ImpossibleTravel": {
"confidence": "high",
"code": "initial_login"
}
}
}
},
"hostname": "XXXXXXX.eu.auth0.com",
"user_id": "XXXXXXXX",
"user_name": "XXXX#XXXX.com",
"audience": "https://XXXXXXX.eu.auth0.com/userinfo",
"scope": [
"openid",
"profile",
"email"
],
"auth0_client": {
"name": "auth0-react",
"version": "1.9.0"
},
"log_id": "900202202280905566349491050266127672706556666XXXXXXX",
"_id": "900202202280905566349491050266127672706556666XXXXXXX",
"isMobile": false
}
What i've been trying so far:
Created a new Auth0 account and connect the sample React Login application (https://github.com/auth0-samples/auth0-react-samples/tree/master/Sample-01) provided by Auth0 to the same Active Directory endpoint (works)
Connect our Development Auth0 account to Active Directory using the Auth0 React sample app (doesn't work)
Connect our React development application to the Active Directory Endpoint (throws error as shown above)
Playing around with different Callback URLs. Added some URLs and Routes to the existing http://localhost:3000 (doesn't work)
I think this error was caused by wrong settings in our Auth0 account since creating a new account doesn't show any problems. I also don't see any issues caused by setting up the Active Directory application.

How to refer to list during with_dict loop

I am trying to build playbook that dynamically queries Windows' registry to detect installed instances of SQL Server (or anything else), its version, location, etc. and do X action for every instance. This works ok if only one SQL instance is installed but I am not sure how to achieve this in multi-instance environment as I am mixing dicts and list and I am not sure how to solve this..
As a simple example playbook below detects installed SQL instances based on reg keys and checks version of SQL for each instance. I would like to out the info on per instance basis (or even better put this into dict variable so I can use it later and add more details based on other reg keys).
Problem is that some of the returned data is a list and I am not sure how to add it to the loop (or add it to dict where key is the instance for example).
Code:
- name: 'Go to Windows registry and check if any SQL instance is installed - using win_reg_stat module'
win_reg_stat:
path: HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\Instance Names\SQL
register: reg_InstalledInstances
- name: 'Go to Windows registry and for each installed instance get its version number'
win_reg_stat:
path: HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\{{item.value.raw_value}}\MSSQLServer\CurrentVersion
name: CurrentVersion
with_dict: '{{reg_InstalledInstances.properties}}'
register: reg_CurrentVersion
- debug:
msg:
- '{{reg_CurrentVersion}}'
- name: 'Show all the details'
debug:
msg:
- 'Hostname: {{inventory_hostname}}'
- 'SQL Instance: {{item.key}}'
- 'SQL Instance in Registry: {{item.value.raw_value}}'
#- 'CurrentVersion: {{reg_CurrentVersion.results.raw_value}}'
with_dict: '{{reg_InstalledInstances.properties}}'
- name:
debug:
msg:
- '{{reg_CurrentVersion}}'
Problem:
I am not sure how to refer reg_CurrentVersion into the loop - in the loop (i tried {{reg_CurrentVersion.results.item.raw_value}} as well):
...
- 'CurrentVersion: {{reg_CurrentVersion.results.raw_value}}'
with_dict: '{{reg_InstalledInstances.properties}}'
results in:
the task includes an option with an undefined variable. The error was: 'list object' has no attribute 'raw_value'
reg_CurrentVersion on its own works fine and looks like this:
ok: [gbltcdevcmdr01] => {
"msg": [
{
"changed": false,
"msg": "All items completed",
"results": [
{
"ansible_loop_var": "item",
"changed": false,
"exists": true,
"failed": false,
"item": {
"key": "SQL2014",
"value": {
"raw_value": "MSSQL12.SQL2014",
"type": "REG_SZ",
"value": "MSSQL12.SQL2014"
}
},
"raw_value": "12.0.6024.0",
"type": "REG_SZ",
"value": "12.0.6024.0"
},
{
"ansible_loop_var": "item",
"changed": false,
"exists": true,
"failed": false,
"item": {
"key": "SQL2016",
"value": {
"raw_value": "MSSQL13.SQL2016",
"type": "REG_SZ",
"value": "MSSQL13.SQL2016"
}
},
"raw_value": "13.2.5026.0",
"type": "REG_SZ",
"value": "13.2.5026.0"
},
{
"ansible_loop_var": "item",
"changed": false,
"exists": true,
"failed": false,
"item": {
"key": "MSSQLSERVER",
"value": {
"raw_value": "MSSQL11.MSSQLSERVER",
"type": "REG_SZ",
"value": "MSSQL11.MSSQLSERVER"
}
},
"raw_value": "11.0.7001.0",
"type": "REG_SZ",
"value": "11.0.7001.0"
},
{
"ansible_loop_var": "item",
"changed": false,
"exists": true,
"failed": false,
"item": {
"key": "SQL2017",
"value": {
"raw_value": "MSSQL14.SQL2017",
"type": "REG_SZ",
"value": "MSSQL14.SQL2017"
}
},
"raw_value": "14.0.1000.169",
"type": "REG_SZ",
"value": "14.0.1000.169"
}
]
}
]
}
EDIT:
at the moment if I run the initial code:
...
- name: 'Show all the details'
debug:
msg:
- 'Hostname: {{inventory_hostname}}'
- 'SQL Instance: {{item.key}}'
- 'SQL Instance in Registry: {{item.value.raw_value}}'
#- 'CurrentVersion: {{reg_CurrentVersion.results.raw_value}}'
with_dict: '{{reg_InstalledInstances.properties}}'
I got this:
ok: [testhost] => (item={'key': 'SQL2014', 'value': {'raw_value': 'MSSQL12.SQL2014', 'value': 'MSSQL12.SQL2014', 'type': 'REG_SZ'}}) => {
"msg": [
"Hostname: testhost",
"SQL Instance: SQL2014",
"SQL Instance in Registry: MSSQL12.SQL2014"
]
}
ok: [testhost] => (item={'key': 'SQL2016', 'value': {'raw_value': 'MSSQL13.SQL2016', 'value': 'MSSQL13.SQL2016', 'type': 'REG_SZ'}}) => {
"msg": [
"Hostname: testhost",
"SQL Instance: SQL2016",
"SQL Instance in Registry: MSSQL13.SQL2016"
]
}
ok: [testhost] => (item={'key': 'MSSQLSERVER', 'value': {'raw_value': 'MSSQL11.MSSQLSERVER', 'value': 'MSSQL11.MSSQLSERVER', 'type': 'REG_SZ'}}) => {
"msg": [
"Hostname: testhost",
"SQL Instance: MSSQLSERVER",
"SQL Instance in Registry: MSSQL11.MSSQLSERVER"
]
}
ok: [testhost] => (item={'key': 'SQL2017', 'value': {'raw_value': 'MSSQL14.SQL2017', 'value': 'MSSQL14.SQL2017', 'type': 'REG_SZ'}}) => {
"msg": [
"Hostname: testhost",
"SQL Instance: SQL2017",
"SQL Instance in Registry: MSSQL14.SQL2017"
]
}
I would like to simply add reg_CurrentVersion.results.raw_value as an extra line for each instance. Something like below:
ok: [testhost] => (item={'key': 'SQL2014', 'value': {'raw_value': 'MSSQL12.SQL2014', 'value': 'MSSQL12.SQL2014', 'type': 'REG_SZ'}}) => {
"msg": [
"Hostname: testhost",
"SQL Instance: SQL2014",
"SQL Instance in Registry: MSSQL12.SQL2014"
"CurrentVersion: 12.0.6024.0"
]
}
ok: [testhost] => (item={'key': 'SQL2016', 'value': {'raw_value': 'MSSQL13.SQL2016', 'value': 'MSSQL13.SQL2016', 'type': 'REG_SZ'}}) => {
"msg": [
"Hostname: testhost",
"SQL Instance: SQL2016",
"SQL Instance in Registry: MSSQL13.SQL2016"
"CurrentVersion: 13.2.5026.0"
]
}
ok: [testhost] => (item={'key': 'MSSQLSERVER', 'value': {'raw_value': 'MSSQL11.MSSQLSERVER', 'value': 'MSSQL11.MSSQLSERVER', 'type': 'REG_SZ'}}) => {
"msg": [
"Hostname: testhost",
"SQL Instance: MSSQLSERVER",
"SQL Instance in Registry: MSSQL11.MSSQLSERVER"
"CurrentVersion: 11.0.7001.0"
]
}
ok: [testhost] => (item={'key': 'SQL2017', 'value': {'raw_value': 'MSSQL14.SQL2017', 'value': 'MSSQL14.SQL2017', 'type': 'REG_SZ'}}) => {
"msg": [
"Hostname: testhost",
"SQL Instance: SQL2017",
"SQL Instance in Registry: MSSQL14.SQL2017"
"CurrentVersion: 14.0.1000.169"
]
}
PS. Is there a way to build dict and append new values to it later on?
Tomasz
Q: "Is there a way to build a dictionary and append new values to it later on?"
A: Yes. It's possible. Let's create the dictionary with the data
- set_fact:
mylist: "{{ reg_CurrentVersion.results|
json_query('[].{instance: item.key,
registry: item.value.raw_value,
version: raw_value}') }}"
- debug:
var: mylist
gives
"mylist": [
{
"instance": "SQL2014",
"registry": "MSSQL12.SQL2014",
"version": "12.0.6024.0"
},
{
"instance": "SQL2016",
"registry": "MSSQL13.SQL2016",
"version": "13.2.5026.0"
},
{
"instance": "MSSQLSERVER",
"registry": "MSSQL11.MSSQLSERVER",
"version": "11.0.7001.0"
},
{
"instance": "SQL2017",
"registry": "MSSQL14.SQL2017",
"version": "14.0.1000.169"
}
]
Append hostname to each dictionary
- set_fact:
mylist2: "{{ mylist2|default([]) +
[item|combine({'hostname': inventory_hostname})] }}"
loop: "{{ mylist }}"
- debug:
var: mylist2
gives
"mylist2": [
{
"hostname": "localhost",
"instance": "SQL2014",
"registry": "MSSQL12.SQL2014",
"version": "12.0.6024.0"
},
{
"hostname": "localhost",
"instance": "SQL2016",
"registry": "MSSQL13.SQL2016",
"version": "13.2.5026.0"
},
{
"hostname": "localhost",
"instance": "MSSQLSERVER",
"registry": "MSSQL11.MSSQLSERVER",
"version": "11.0.7001.0"
},
{
"hostname": "localhost",
"instance": "SQL2017",
"registry": "MSSQL14.SQL2017",
"version": "14.0.1000.169"
}
]

Couchbase lite .net SDK Replication Error

I'm working with couchbase lite .net sdk, and I got a example from below url.
and my configuration file is like below.
{
"log": ["HTTP+"],
"adminInterface": "0.0.0.0:4985",
"interface": "0.0.0.0:4984",
"databases": {
"db": {
"server": "walrus:data",
"bucket": "todo",
"users": {
"GUEST": {"disabled": false, "admin_channels": ["*"] }
}
}
}
}
when I run the wpf app, I'm getting error like below image.
image
Please help me, I'm not sure how to implement couchbase sync gateway.
I fixed the issue.
I add shadow property to configuration json file.
You can read more information from these links.
https://groups.google.com/forum/#!topic/mobile-couchbase/NWd8xqPOjsc
https://github.com/couchbase/sync_gateway/wiki/Bucket-Shadowing
{
"interface": ":4984",
"adminInterface": ":4985",
"log": [ "*" ],
"databases": {
"sync_gateway": {
"server": "walrus:",
"bucket": "sync_gateway",
"users": {
"GUEST": {
"disabled": false,
"admin_channels": [ "*" ]
},
"user": {
"admin_channels": [ "*" ],
"password": "user"
}
},
"sync": `function(doc){ "channel(doc.channels); }`,
,
"shadow": {
"server": "http://couchbase-dev.thisisdmg.com:8091",
"bucket": "sales_agent"
}
}
}
}

Resources