Unable to sparql query paranet: Request failed with status code 500
Steps:
- run a testnet node on base testnet
- create a paranet
- create assets on the paranet
- paranet sync on the testnet node (sync verified working in the logs)
- run a sparql query to that paranet using same priv key that created paranet
require('dotenv').config();
const DKGClient = require('dkg.js');
const node_options = {
endpoint: process.env.OTNODE_HOST || 'http://localhost',
port: process.env.OTNODE_PORT || '8900',
blockchain: {
name: process.env.BLOCKCHAIN_NAME || 'base:84532',
privateKey: process.env.PRIVATE_KEY || '',
},
maxNumberOfRetries: parseInt(process.env.MAX_NUMBER_OF_RETRIES) || 300,
frequency: parseInt(process.env.FREQUENCY) || 2,
contentType: process.env.CONTENT_TYPE || 'all',
nodeApiVersion: '/v1',
useSSL: process.env.USE_SSL,
};
// Load PARANET_UAL
const PARANET_UAL = process.env.PARANET_UAL || 'did:dkg:base:84532/0xd5550173b0f7b8766ab2770e4ba86caf714a5af5/191718/1';
function validateConfig(config, paranetUAL) {
console.log('Validating configuration...');
const requiredStringFields = ['endpoint', 'port'];
for (const field of requiredStringFields) {
if (typeof config[field] !== 'string' || !config[field]) {
throw new Error(`Invalid configuration: Missing or invalid value for '${field}'`);
}
}
if (!config.blockchain || typeof config.blockchain !== 'object') {
throw new Error("Invalid configuration: 'blockchain' must be an object");
}
const blockchainFields = ['name', 'privateKey'];
for (const field of blockchainFields) {
if (typeof config.blockchain[field] !== 'string' || !config.blockchain[field]) {
throw new Error(`Invalid configuration: Missing or invalid value for 'blockchain.${field}'`);
}
}
if (!paranetUAL || typeof paranetUAL !== 'string') {
throw new Error("Invalid configuration: 'PARANET_UAL' must be a string");
}
const ualPattern = /^did:dkg:base:84532\/0x[a-fA-F0-9]{40}\/\d+\/\d+$/;
if (!ualPattern.test(paranetUAL)) {
throw new Error("Invalid configuration: 'PARANET_UAL' has an invalid format");
}
console.log('Configuration validated successfully.');
console.log('Config:', {
endpoint: config.endpoint,
port: config.port,
blockchain: config.blockchain.name,
maxNumberOfRetries: config.maxNumberOfRetries,
frequency: config.frequency,
paranetUAL: paranetUAL,
});
}
// Initialize DKG Client
try {
validateConfig(node_options, PARANET_UAL);
} catch (error) {
console.error('Configuration validation failed:', error.message);
process.exit(1);
}
const dkg = new DKGClient(node_options);
// SPARQL query to retrieve Dataset assets
const sparqlQuery = `
PREFIX SCHEMA: <http://schema.org/>
SELECT DISTINCT ?asset ?name ?description ?keywords ?datePublished
WHERE {
?asset a SCHEMA:Dataset ;
SCHEMA:name ?name ;
SCHEMA:description ?description .
OPTIONAL { ?asset SCHEMA:keywords ?keywords . }
OPTIONAL { ?asset SCHEMA:datePublished ?datePublished . }
}
LIMIT 10
`.trim();
async function executeQuery() {
try {
// Verify node connection
console.log('Checking node connection...');
const nodeInfo = await dkg.node.info();
console.log('Connected to node:', JSON.stringify(nodeInfo, null, 2));
// Wait for graph propagation
console.log('Waiting for graph propagation...');
await new Promise(resolve => setTimeout(resolve, 100));
// Execute query with PARANET_UAL
console.log('Executing SPARQL query with PARANET_UAL:\n', sparqlQuery);
console.log('Query options:', {
blockchain: node_options.blockchain.name,
maxNumberOfRetries: node_options.maxNumberOfRetries,
frequency: node_options.frequency,
paranetUAL: PARANET_UAL,
});
let queryResult;
try {
queryResult = await dkg.graph.query(sparqlQuery, 'SELECT', {
blockchain: {
name: node_options.blockchain.name,
privateKey: node_options.blockchain.privateKey,
},
maxNumberOfRetries: node_options.maxNumberOfRetries,
frequency: node_options.frequency,
paranetUAL: PARANET_UAL,
});
} catch (queryError) {
console.error('Raw query error:', queryError.message);
throw new Error(`DKG query failed: ${queryError.message}`);
}
if (!queryResult || !queryResult.data) {
throw new Error('DKG query failed: No data returned');
}
const results = queryResult.data.map(entry => {
const formattedParts = Object.keys(entry).map(key => `${key}: ${entry[key]}`);
return formattedParts.join(', ');
});
console.log('Query results:', JSON.stringify(results, null, 2));
} catch (error) {
console.error('Error executing query:', error.message);
console.error('Error details:', JSON.stringify(error, null, 2));
throw error;
}
}
// Run the script
executeQuery().catch(error => {
console.error('Execution failed:', error.message);
console.error('Stack trace:', error.stack);
process.exit(1);
});
Error returned:
Raw query error: Unable to query: Request failed with status code 500 Error executing query: DKG query failed: Unable to query: Request failed with status code 500 Error details: {} Execution failed: DKG query failed: Unable to query: Request failed with status code 500 Stack trace: Error: DKG query failed: Unable to query: Request failed with status code 500 at executeQuery (/root/dkg-scripts/paranetSparqlQuery.js:111:13) at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
This should be SPARQL validation error.
Query looks good, can you share some small part of dataset or UALs if data is public so I can test?
Thanks for the help, here's the asset info and open paranet UAL:
ParanetUAL on base testnet: did:dkg:base:84532/0xd5550173b0f7b8766ab2770e4ba86caf714a5af5/190099/1 or did:dkg:base:84532/0xd5550173b0f7b8766ab2770e4ba86caf714a5af5/191718/1
assets are all public.
{
"public": {
"@context": "http://schema.org",
"@type": "Event",
"name": "AIClimateModel",
"description": "An AI model predicts climate change impacts with unprecedented accuracy. Is this technology real?",
"image": "https://yourdomain.com/game/media/event1.jpg",
"startDate": "2025-05-21T15:49:00Z",
"eventStatus": "https://schema.org/EventScheduled",
"eventAttendanceMode": "https://schema.org/OnlineEventAttendanceMode",
"isReal": true,
"eventType": "question",
"keywords": ["AI", "climate change", "technology"],
"organizer": {
"@type": "Organization",
"name": "Swarm of Truth"
},
"license": "https://creativecommons.org/licenses/by/4.0/"
}
}
{
"public": {
"@context": "http://schema.org",
"@type": "Event",
"name": "DeepFakeCelebrityVideo",
"description": "A viral video shows a celebrity endorsing a suspicious product. Is it real or a deep fake?",
"isReal": false,
"image": "https://yourdomain.com/game/media/event1.jpg",
"eventType": "question",
"keywords": ["deepFake", "misinformation", "video"],
"creator": {
"@type": "Organization",
"name": "Swarm of Truth"
},
"datePublished": "2025-05-13T22:55:00Z",
"license": "https://creativecommons.org/licenses/by/4.0/"
}
}
{
"public": {
"@context": "http://schema.org",
"@type": "Event",
"name": "AIDiagnosticTool",
"description": "An AI tool diagnoses rare diseases faster than human doctors. Is this technology real?",
"isReal": true,
"image": "https://yourdomain.com/game/media/event2.jpg",
"eventType": "question",
"keywords": ["AI", "healthcare", "technology"],
"creator": {
"@type": "Organization",
"name": "Swarm of Truth"
},
"datePublished": "2025-05-13T22:55:00Z",
"license": "https://creativecommons.org/licenses/by/4.0/"
}
}
{
"public": {
"@context": "http://schema.org",
"@type": "Event",
"name": "AIArtGenerator",
"description": "An AI creates paintings indistinguishable from human artists. Is this technology real?",
"isReal": true,
"image": "https://yourdomain.com/game/media/event1.jpg",
"eventType": "question",
"keywords": ["AI", "art", "technology"],
"creator": {
"@type": "Organization",
"name": "Swarm of Truth"
},
"datePublished": "2025-05-21T15:49:00Z",
"license": "https://creativecommons.org/licenses/by/4.0/"
}
}
node get-ual-info.js works fine:
Connected to node: { version: '8.0.12+hotfix.2' } Fetching data for Paranet UAL: did:dkg:base:84532/0xd5550173b0f7b8766ab2770e4ba86caf714a5af5/190099/1 Paranet Data: { "assertion": [ { "@id": "uuid:11d3c18e-3555-4dd4-a0d7-775598a8b5d4", "http://schema.org/name": [ { "@value": "dkg swarm test" } ], "@type": [ "http://schema.org/DataCatalog" ] } ], "operation": { "get": { "operationId": "1cfedfd3-861e-4bb0-a296-dc86ec2ec94b", "status": "COMPLETED" } } }