Skip to content

Incosistent error for CAPABILITY_REGEX check: hyphens or underscores? #42

@marshallmcdonnell

Description

@marshallmcdonnell

In 0.9.0, for a service we are trying to create called intersect-chess-instrument-control-service, we are getting an error about the capability name.

> CRITICAL:intersect-sdk:Invalid intersect_sdk_capability_name on capability ChessInstrumentControlCapability - must be a non-empty string with only alphanumeric characters and hyphens (you must explicitly set this, and do so on the class and not an instance).

The line that violated this check was intersect_sdk_capability_name=chess-instrument-control

Yet, there are hyphens in the name, which by the error message should work.

That error is defined here: https://github.com/INTERSECT-SDK/python-sdk/blob/main/src/intersect_sdk/_internal/schema.py#L614-L628

The capabilitiy regex is defined here: https://github.com/INTERSECT-SDK/python-sdk/blob/v0.9.0/src/intersect_sdk/constants.py#L12

The regex shows ^[a-zA-Z0-9]\w*$
According to this, the \w is the issue.
Docs: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Character_class_escape

Mainly, udderscores are allowed by \w but hyphens are not.

Simple fix for the capability name is change from chess-instrument-control to chess_instrument_control.

Yet, do we want to allow hyphens instead?

====

From issue in this intersect service: nsdf-fabric/intersect-chess-instrument-control-service#4 (comment)

@k1nho was reviewing PR, found different behavior between 0.8.3 and 0.9 versions of SDK, see below

I am running the compose setup and ran into this error for the version defined of intersect-sdk

CRITICAL:intersect-sdk:Invalid intersect_sdk_capability_name on capability ChessInstrumentControlCapability - must be a non-empty string with only alphanumeric characters and hyphens (you must explicitly set this, and do so on the class and not an instance).

After changing to intersect-sdk 0.8.3 the one we used previously, I got a better error

CRITICAL:intersect-sdk:On capability 'ChessInstrumentControlCapability', parameter 'config' type annotation 'ExperimentConfig' on function 'initialize_experiment' is in
valid TypeAdapter[ExperimentConfig] is not fully defined; you should define ExperimentConfig and all referenced types, then call .rebuild() on the instance.

For further information visit https://errors.pydantic.dev/2.12/u/class-not-fully-defined

It seems that there is some error that has to do with TypeAdapter, and that is caused by the from future import annotations on the service.py, data_models.py and file_writer.py. After removing them the intersect service ran correctly (intersect-sdk0.8.3, 0.9.0 still fails with the first error). Is there a reason why those are needed?

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions