Custom Oracle node in n8n: Credential test function not recognized

Hey folks, I’m stuck with a problem while creating my own node for Oracle in n8n. The system keeps telling me there’s no test function for my credentials, even though I’ve set one up.

I’ve got a credentials file without any auth or test methods. Instead, I’ve put a separate test function in the node.ts file. Here’s what I’ve done:

In node.ts:

credentials: [
  {
    name: 'oracleConnect',
    required: true,
    testedBy: 'validateCredentials'
  }
],

methods = {
  dbOperations: {
    queryTables
  },
  credentialTest: {
    validateCredentials
  }
};

The validateCredentials function matches the ICredentialTestFunction interface:

type CredentialTestFunc = (this: CredentialTestFuncs, cred: DecryptedCreds) => Promise<CredTestResult>;

I’ve checked other database nodes like PostgreSQL, and they seem to do it this way. But for some reason, my setup isn’t working. Any ideas what I’m missing here? Thanks!

I’ve encountered this issue before when developing custom nodes for n8n. One thing that’s often overlooked is the need to register the credential test function in the main file of your node package. Try adding this line to your main file (usually index.ts):

import { validateCredentials } from './YourNodeName.node';

NodeOperations.registerNodeType({
  // ... other node registration details
  credentials: [
    {
      name: 'oracleConnect',
      required: true,
    },
  ],
  credentialTest: { validateCredentials },
});

This explicitly tells n8n where to find your credential test function. If that doesn’t work, double-check your imports and exports to ensure the function is properly exposed. Let me know if you need any more help!

hey there neo_stars! i’ve run into similar issues before. have you tried moving the validateCredentials function directly into the credentials file? sometimes n8n can be picky about where it looks for test functions. also, double-check that your function name matches exactly in both places. hope this helps!

Have you considered the possibility that the issue might be related to how n8n is interpreting your node structure? Sometimes, the framework can be quite particular about the exact placement and naming of functions. One thing you could try is to restructure your code slightly. Instead of using the ‘methods’ object, try defining your functions directly on the node class:

export class YourNodeName implements INodeType {
  description = {
    // ... your node description
    credentials: [
      {
        name: 'oracleConnect',
        required: true,
        testedBy: 'validateCredentials',
      },
    ],
  };

  async validateCredentials(credentials: ICredentialDataDecryptedObject): Promise<INodeCredentialTestResult> {
    // Your validation logic here
  }

  async execute() {
    // Your execute method
  }
}

This approach aligns more closely with how n8n typically expects custom nodes to be structured. It might resolve the issue of n8n not recognizing your test function. If this doesn’t work, you may need to review how your node is being exported and registered within the n8n ecosystem.