Skip to content

[Bug] gitt issues register cannot encode register_issue string arguments after #1335 #1375

Description

@statxc

Description

After #1335, gitt issues register no longer goes through ContractInstance.exec(...). It now routes through the new IssueCompetitionContractClient.register_issue(...) method, which calls _exec_contract_raw('register_issue', ...)_encode_args('register_issue', ...).

That new path is broken before any extrinsic is submitted.

metadata.json declares register_issue with two str arguments:

  • github_url
  • repository_full_name

But IssueCompetitionContractClient._encode_args() only handles u32, u64, u128, AccountId, and array32. Anything else hits the fallback:

raise ValueError(f'Unsupported type: {type_def} for arg {arg_name}')

So every register_issue call fails while encoding github_url, before compose_call is ever invoked.

Affected Code

  • gittensor/cli/issue_commands/mutations.pyissue_register() now calls client.register_issue(...) (introduced in Bump bittensor stack and drop substrate-interface #1335).
  • gittensor/validator/issue_competitions/contract_client.py
    • register_issue()_exec_contract_raw(method_name='register_issue', ...)
    • _exec_contract_raw()_encode_args(...)
    • _encode_args() has no str branch.
  • gittensor/validator/issue_competitions/metadata.jsonregister_issue declares github_url and repository_full_name as str.

Steps to Reproduce

No live chain required — the failure happens entirely inside local argument encoding.

Against current test at fc503f9:

from gittensor.validator.issue_competitions.contract_client import (
    IssueCompetitionContractClient,
)

# Bypass __init__ so we don't need a Subtensor connection.
client = IssueCompetitionContractClient.__new__(IssueCompetitionContractClient)

client._encode_args(
    "register_issue",
    {
        "github_url": "https://github.com/owner/repo/issues/1",
        "repository_full_name": "owner/repo",
        "issue_number": 1,
        "target_bounty": 10_000_000_000,
    },
)

Observed:

ValueError: Unsupported type: str for arg github_url

The full CLI path reaches the same encoder via:

gitt issues register
  → mutations.issue_register()
  → IssueCompetitionContractClient.register_issue(...)
  → _exec_contract_raw(method_name="register_issue", ...)
  → _encode_args("register_issue", ...)   # raises here

Expected Behavior

gitt issues register should encode the register_issue arguments and submit the contract call. Specifically, _encode_args should SCALE-encode str as compact-length-prefixed UTF-8 bytes (the SCALE encoding of Vec<u8>).

Actual Behavior

register_issue fails during local argument encoding, before any on-chain submission. The CLI can only surface a pre-submission error similar to:

register_issue error: Unsupported type: str for arg github_url

Impact

#1335 was intended to remove the local .contract artifact requirement for issue registration ("removes the runtime requirement to have smart-contracts/issues-v0/target/ink/issue_bounty_manager.contract built locally before registering an issue"). The replacement path achieves that goal but cannot register any issue, because register_issue always carries string arguments.

This breaks the owner-only gitt issues register workflow on current test.

#1335's own description notes that "Basic things were tested, but not the chain interaction itself" — this is the gap that comment was flagging.

Suggested Fix

Add SCALE string encoding to _encode_args() for type_def == "str":

  • UTF-8-encode the value.
  • Prepend the SCALE compact length of the byte string.
  • Append the bytes.

The compact-length helper should cover at least modes 0 (n < 64), 1 (64 ≤ n < 16384), and 2 (16384 ≤ n < 2³⁰) so that longer repo names / URLs don't fail at the >64-byte boundary.

A regression test should cover register_issue specifically, e.g.:

  • Construct the client via __new__ (no chain dependency).
  • Call _encode_args("register_issue", {...}) with both a short URL and a URL long enough to push the encoded length past 64 bytes.
  • Assert it does not raise.
  • Assert the encoded bytes begin with the correct SCALE compact-length prefix followed by the UTF-8 bytes, in order, for github_url then repository_full_name, then u32 issue_number (4 bytes LE), then u128 target_bounty (16 bytes LE).
  • Negative case: a non-str value for github_url raises a clear error.

Prior Art / Not a Duplicate

#987 / #988 (and the parallel #993) proposed removing the str fallback as dead code, with bodies explicitly stating:

"str appears only in register_issue (never routed here)… register_issue is never called through _exec_contract_raw_encode_args — it is called from the CLI (mutations.py) via a different execution path."

That premise was true at the time, and those PRs were closed without merging.

#1335 inverted that premise: register_issue is now routed through _exec_contract_raw()_encode_args(), making the previously unreachable str path reachable in production — and now broken, because the str branch was never implemented.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions