Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 19, 2025

urlparse() misinterprets identifiers with colons (e.g., cpb-aacip-507-v40js9j432:video) as having a URI scheme, causing the code to use the wrong scheme and incorrectly strip characters.

Changes

  • mmif/utils/cli/source.py: Check if parsed scheme matches the provided scheme parameter. When they differ (and it's not file://), use the scheme parameter with the full location string instead of the misinterpreted components.

  • tests/test_utils_cli.py: Add test case for locations containing colon separators.

Example

# Before (buggy):
# Input: --scheme baapb video:cpb-aacip-507-v40js9j432:video
# Output: cpb-aacip-507-v40js9j432://deo

# After (fixed):
# Input: --scheme baapb video:cpb-aacip-507-v40js9j432:video  
# Output: baapb://cpb-aacip-507-v40js9j432:video

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/repos/clamsproject/mmif-python/git/refs/tags
    • Triggering command: curl --silent REDACTED (http block)
  • https://api.github.com/repos/clamsproject/mmif/git/refs/tags
    • Triggering command: curl --silent REDACTED (http block)
  • https://api.github.com/repos/clamsproject/mmif/tags
    • Triggering command: `/usr/bin/python3 -c
      exec(compile('''

This is <pip-setuptools-caller> -- a caller that pip uses to run setup.py

- It imports setuptools before invoking setup.py, to enable projects that directly

import from distutils.core to work with newer packaging standards.

- It provides a clear error message when setuptools is not installed.

- It sets sys.argv[0] to the underlying setup.py, when invoking setup.py so

setuptools doesn't think the script is -c. This avoids the following warning:

manifest_maker: standard file '-c' not found".

- It generates a shim setup.py, for handling setup.cfg-only projects.

import os, sys, tokenize

try:
import setuptools
except ImportError as error:
print(
"ERROR: Can not execute setup.py since setuptools is not available in "
"the build environment.",
file=sys.stderr,
)
sys.exit(1)

file = %r
sys.argv[0] = file

if os.path.exists(file):
filename = file
with tokenize.open(file) as f:
setup_py_code = f.read()
else:
filename = "<auto-generated setuptools caller>"
setup_py_code = "from setuptools import setup; setup()"

exec(compile(setup_py_code, filename, "exec"))
''' % ('/home/REDACTED/work/mmif-python/mmif-python/setup.py',), "<pip-setuptools-caller>", "exec")) develop --no-deps --user --prefix=` (http block)

  • Triggering command: python3 setup.py sdist (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>source MMIF generation bug when using --scheme option</issue_title>
<issue_description>

doc.properties.location = f"{location_uri.scheme}://{location if not location.startswith(location_uri.scheme) else location[len(location_uri.scheme)+3:]}"

Something is wrong here...

$ mmif source --scheme baapb video:${id}:video  
{
  "metadata": {
    "mmif": "http://mmif.clams.ai/1.1.0"
  },
  "documents": [
    {
      "@type": "http://mmif.clams.ai/vocabulary/VideoDocument/v1",
      "properties": {
        "mime": "video",
        "id": "d1",
        "location": "cpb-aacip-507-v40js9j432://deo"
      }
    }
  ],
  "views": []

The location value should be "baaps://cpb-aacip-507-v40js9j432.video"</issue_description>

<agent_instructions>fix character indexing bug</agent_instructions>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits November 19, 2025 01:36
Co-authored-by: keighrim <9062727+keighrim@users.noreply.github.com>
Co-authored-by: keighrim <9062727+keighrim@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix source MMIF generation bug with --scheme option Fix scheme handling when location contains colon separator Nov 19, 2025
Copilot AI requested a review from keighrim November 19, 2025 01:42
@keighrim keighrim closed this Nov 19, 2025
@keighrim keighrim deleted the copilot/fix-character-indexing-bug branch November 20, 2025 16:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

source MMIF generation bug when using --scheme option

2 participants